js等比例缩放图片
2016-06-30来源:

<script language=javascript>

<!--

var flag=false;

function drawimage(imgd){

var image=new image();

image.src=imgd.src;

if(image.width>0 && image.height>0){

flag=true;

if(image.width/image.height>= 164/112){

if(image.width>164){

imgd.width=164;

imgd.height=(image.height*164)/image.width;

}else{

imgd.width=image.width;

imgd.height=image.height;

} //forasp

imgd.alt=image.width+x+image.height;

}

else{

if(image.height>112){

imgd.height=112;

imgd.width=(image.width*112)/image.height;

}else{

imgd.width=image.width;

imgd.height=image.height;

}

imgd.alt=image.width+x+image.height;

}

}

} //-->

</script>

<a href=./img.jpg target=_blank><img src=5_1.jpg border=0 width=164 height=112 onload=javascript:drawimage(this);></a>

推荐信息
Baidu
map