为什么要将图片拉扯得不象样,
能不能考虑:只定义宽度,让它按比例显示:
<img src="../My%20Documents/My%20Pictures/tuzehui.jpg" width=300 >
(注意:用width=300,不是用style="width:300")

解决方案 »

  1.   

    操,用frontpage预览的效果是图片被拉乱了,但是通过页面试问却正常
    最好是去测试一下不同的IE版本是否支持这样做。先隐藏再显示,跳来跳去的效果可能会弱一点
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language=javascript>function DrawImage(ImgD){ 
    alert();
     var image=new Image(); 
     image.src=ImgD.src; 
     if(image.width>image.height*3){ 
       if(image.width>300){ 
       ImgD.width=300; 
                          }
                                      }
    else{
       if(image.height>=100){
         ImgD.height=100; 
                            }
        }
    ImgD.style.display="";  
    }</script><title>New Page 2</title>
    </head><body ><img src="../My%20Documents/My%20Pictures/tuzehui.jpg" name="boss" onload="DrawImage(this)" style="display:none"></body></html>
      

  2.   

    楼上的朋友JK_10000(JK),你的代码运行有错误啊,它会条出一个警告框,但里面什么也没写!但我不知道错误在哪里,谁能看出来??
      

  3.   

    跳出了个  alert(),
    是用来观看如果网速很慢时的效果,
    不是错误
    去掉就是
      

  4.   

    你这样试试:将你的源html的这句:
    <img src="images/aaa.jpg" name="boss" onload="javascript:DrawImage(this);">改为:
    <img src="images/aaa.jpg" name="boss" onload="javascript:DrawImage(this);" width="0">这样load的时候就不会显示,更不会出现什么原始大小了。^_^
      

  5.   

    真奇怪,WIDHT="0",居然也可以显示!!
      

  6.   

    <img src="images/aaa.jpg" name="boss" onload="javascript:DrawImage(this);" width="0">
    -->>
    <img src="images/aaa.jpg" name="boss" onload="javascript:DrawImage(this);" width="1">
    0对于width来说,是无效的,相当于没有赋。
      

  7.   

    "0对于width来说,是无效的,相当于没有赋。"——其实也未必,我给出两段代码大家可以看到效果并不一样!其中一个没了,一个却还在!1)----------------------------------------------------------------------
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    <script language="javascript"> 
    var flag=false;  
    function DrawImage(ImgD){  
       var image=new Image(); 
       image.src=ImgD.src;  
       if(image.width>0 && image.height>0){  
        flag=true;  
        if(image.width/image.height>=500/400){  
         if(image.width>100){    
         ImgD.width=100;  
         ImgD.height=(image.height*100)/image.width;  
         }else{  
         ImgD.width=image.width;    
         ImgD.height=image.height;  
         }  
         }  
        else{  
         if(image.height>100){    
         ImgD.height=100;  
         ImgD.width=(image.width*200)/image.height;       
         }else{  
         ImgD.width=image.width;    
         ImgD.height=image.height;  
         }  
         }  
        }  
       }   
    </script>
    </head><body><table border="0" width="227" height="96" align="left">
    <tr>
    <td height="50" width="300">
    <img border="0" src="images/2.jpg" onload="javascript:DrawImage(this)" width="0"> </td>
    </tr>
    <tr>
    <td height="50" width="300">
    <a href="new_page_0.htm">
    <img border="0" src="images/3.jpg" onload="javascript:DrawImage(this)" width="0"></a></td>
    </tr>
    </table></body></html>2)---------------------------------------------------------------------------------
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    <script language="javascript"> 
    function DrawImage(ImgD){ 
     var image=new Image(); 
     image.src=ImgD.src; 
     if(image.width>image.height*3){ 
       if(image.width>300){ 
       ImgD.width=300; 
                          }
                                      }
    else{
       if(image.height>=100){
         ImgD.height=100; 
                            }
        }
    }
       
    </script>
    </head><body><table border="0" width="227" height="96" align="left">
    <tr>
    <td height="100" width="300">
    <table border="0" width="263" height="320">
    <tr>
    <td height="316" width="263">
    <img border="0" src="images/2.jpg" onload="javascript:DrawImage(this)" width="0"></td>
    </tr>
    </table>
    <a href="new_page_1.htm">
    <img border="0" src="images/2.jpg" onload="javascript:DrawImage(this)" width="0"></a></td>
    </tr>
    </table></body></html>
      

  8.   

    <img src="../My%20Documents/My%20Pictures/tuzehui.jpg" name="boss" width="0" >
    的确是有效果