<script language="javascript">
function DrawImage(ImgD){
var img=new Image();
img.src=ImgD.src;
if(img.width>0&&img.height>0){
flag=true;
if(img.width/img.height>120/80){
if(img.width>120){
ImgD.width=120;
ImgD.height=(img.height*120)/img.width;
}else{
ImgD.width=img.width;
ImgD.height=img.height;
}
ImgD.alt=img.width+"*"+img.height;
}else{
if(img.height>80){
ImgD.height=80;
ImgD.width=(img.width*80)/img.height;
}else{
ImgD.width=img.width;
ImgD.height=img.height;
}
ImgD.alt=img.width+"*"+img.height;
}
}
}
function FileChange(Value)
{
flag=false;
document.all.toString();
document.all.uploadimage.width=10;
document.all.uploadimage.height=10;
document.all.uploadimage.alt="";
document.all.uploadimage.src=Value;
}</script><asp:FileUpload ID="FileUpload1" runat="server" Width="206px" onchange="javascript:FileChange(img);" />
<img id=img height=10 width=10onload="javascript:DrawImage(this)" >
function DrawImage(ImgD){
var img=new Image();
img.src=ImgD.src;
if(img.width>0&&img.height>0){
flag=true;
if(img.width/img.height>120/80){
if(img.width>120){
ImgD.width=120;
ImgD.height=(img.height*120)/img.width;
}else{
ImgD.width=img.width;
ImgD.height=img.height;
}
ImgD.alt=img.width+"*"+img.height;
}else{
if(img.height>80){
ImgD.height=80;
ImgD.width=(img.width*80)/img.height;
}else{
ImgD.width=img.width;
ImgD.height=img.height;
}
ImgD.alt=img.width+"*"+img.height;
}
}
}
function FileChange(Value)
{
flag=false;
document.all.toString();
document.all.uploadimage.width=10;
document.all.uploadimage.height=10;
document.all.uploadimage.alt="";
document.all.uploadimage.src=Value;
}</script><asp:FileUpload ID="FileUpload1" runat="server" Width="206px" onchange="javascript:FileChange(img);" />
<img id=img height=10 width=10onload="javascript:DrawImage(this)" >
为空的原因是你没有name为uploadimage的元素
为空的原因是你没有name为uploadimage的元素uploadimage 指定为img控件的ID是么??
如果是的话,就错了....
我发完这个后,自己改了改,将uploadimage指定给img以后还是显示不出来,不过不报错
document.all.uploadimage.width=10;用这个toString()干什么??这样就转换为字串了。ALL还能是什么ALL??
把这行去掉。