οnlοad="ResizeImg(this,100,100)" //显示图片框的大小
<img src="upfile/proimage/1.jpg" width=300 border=0 height="300" οnlοad="ResizeImg(this,300,300)">
<script type="text/javascript" language="javascript">
function ResizeImg(ImgD,xx,yy){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= xx/yy){
if(image.width>xx){
ImgD.width=xx;
ImgD.height=(image.height*xx)/image.width;
}
else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>yy){
ImgD.height=yy;
ImgD.width=(image.width*yy)/image.height;
}
else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script>