纠结了很长时间了,终于纠结出来了。。。。
<script language="javascript" type="text/javascript">
function DrawImage(ImgD,iwidth)
{
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0)
{
if(image.width>iwidth)
{
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}
}
ImgD.style.display = "block";
}
function setwidth(){
var imgs = document.getElementById("contentdiv").getElementsByTagName("img")
for(var j=0;j<imgs.length;j++){
DrawImage(imgs[j],680);
}
}
setwidth();
</script>