<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000" onload="ini()">
<img id="guagua" src="zdd.jpg">在这里添加你的图片地址
<script language="JavaScript">
function ini()
{if(guagua.width>200)guagua.widht=200;
if(guagua.height>200)guagua.height=200;
}
</script>
</body>
</html>

解决方案 »

  1.   

    sorry
    guagua.widht->guagua.width
      

  2.   

    谢谢zhangguagua(瓜瓜) 我的意思是在200*200区域内,让图片等比例显示,不要变形
      

  3.   

    <script>
    var imarr = [
    new Image(),
    new Image(),
    new Image()
    ];imarr[0].src = "im0.gif";
    imarr[1].src = "im1.gif";
    imarr[2].src = "im2.gif";funtion view(n)
    {
       if(n < 0 || n>imarr.length) return;
       var iw = parseInt(imarr[n].width); iw = (iw==0?1:iw);
       var ih = parseInt(imarr[n].height); ih = (ih==0?1:ih);
       var rate = Math.max(200.0/iw, 200.0/ih);
       if(rate == 0) rate = 1;
       myIMG.width = Math.floor(iw * rate);
       myIMG.height = Math.floor(ih * rate);
       myIMG.src = imarr[n].src;
       myIMG.style.display = "";
    }
    </script>
    <!-- 这段script放到<head></head>之间-->
    <!-- 这段HTML放到<body></body>之间-->
    <img id="myIMG" width="0" height="0" src="" style="display:none">
    <a href="javascript:view(0)">imgage 0</a>
    <a href="javascript:view(1)">imgage 1</a>
    <a href="javascript:view(2)">imgage 2</a>