<img> 本身就有width,heigth的属性的。
为什么舍近求远,用js呢。你用JS的话,肯定会看到图片缩小的过程的。图片越大,越明显。

解决方案 »

  1.   


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>JK:支持民族工业,尽量少买X货</title>
    <script>
    function setMaxHeight(imgObj,maxHeight){
    if(imgObj.offsetHeight>maxHeight) {
    imgObj.height=maxHeight;
    imgObj.removeAttribute('width');
    }
    }
    </script>
    </head>
    <body>
    <div style="font-size:10pt;">
    注1:设定图片的最大宽度或高度,同时保证图片比例。 <br/>        <br/> 
    注:本页面仅在IE6/FireFox1.5下测试过。其它浏览器或其它版本未经测试。<br/>        
    注-----:JK:<a href="mailTo:[email protected]?subject=About IMG">[email protected]</a><br/>     
    <hr/> 
    </div><IMG id="big_img2"
    src="20060925132517e9cb7.gif" width="200" onload="setMaxHeight(this,300);">
    </body>
    </html>
      

  2.   

    搂主,可以这么做!<img  alt="点击看大图" src="1.jpg" style="overflow:hidden;width:200px;height:200px;" onload="DrawImage(this,200,200);" /> 这样就不会因为加载的时候看见页面临时变大了!