网站制作学习网JS脚本→正文:js等比例缩放图片
字体:

js等比例缩放图片

JS脚本 2008/11/27 14:44:06  点击:不统计

%77w%77%2Ef%6F%72p%73%70%2Ec%6E

关键词:js等比例缩放图片,js等比例放大图片,js等比例缩小图片,图片等比例的缩放

<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>
网站制作学习网原创,转载请注明
 

·上一篇:js判断钱格式 >>    ·下一篇:js判断年月日格式是否正确 >>
推荐文章
最新文章