61,114
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script>
function resizeImg(img)
{
if(img.width>200 || img.height>200)
{
if(img.width/img.height>1){
img.width = 200
}
else
{
img.height = 200
}
}
}
</script>
<table style="border:1px solid red;">
<tr><td style="text-align:center;vertical-align:middlee;width:200px;height:200px"><img onload="resizeImg(this)" src="http://i1.sinaimg.cn/dy/2012/0925/U8843P1DT20120925164539.jpg"/></td></tr>
</table>
<br/>
<table style="border:1px solid red;">
<tr><td style="text-align:center;vertical-align:middlee;width:200px;height:200px"><img onload="resizeImg(this)" src="http://www.sinaimg.cn/dy/slidenews/1_img/2012_39/31171_198603_171991.jpg"/></td></tr>
</table>