<body>
<img id="achome" src="http://image2.sina.com.cn/ent/y/2006-10-09/U1819P28T3D1276435F326DT20061009152013.jpg" />
</body>
<script>
// 取得img元素
var imageArr=document.getElementById("achome");
alert("图片原始大小为550x734");
// 图形的宽/高比
imageRate=parseInt(imageArr.style.width)/parseInt(imageArr.style.Height);
//
if(imageArr.offsetWidth>200)
{
alert("现在使图片自适应大小...");
imageArr.style.width="200px";
imageArr.style.height=200/imageRate+"px";
}
</script>
<img id="achome" src="http://image2.sina.com.cn/ent/y/2006-10-09/U1819P28T3D1276435F326DT20061009152013.jpg" />
</body>
<script>
// 取得img元素
var imageArr=document.getElementById("achome");
alert("图片原始大小为550x734");
// 图形的宽/高比
imageRate=parseInt(imageArr.style.width)/parseInt(imageArr.style.Height);
//
if(imageArr.offsetWidth>200)
{
alert("现在使图片自适应大小...");
imageArr.style.width="200px";
imageArr.style.height=200/imageRate+"px";
}
</script>