您的位置:首页 > 编程语言 > ASP

共享一个ASP里的图片自动缩放的JS

2010-07-22 09:51 260 查看
共享一个ASP里的图片自动缩放的JS

JS代码:

<script>
function zoomimg(ImgD,ImgW,ImgH)
{
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= ImgW/ImgH){
if(image.width>ImgW){
ImgD.width=ImgW;
ImgD.height=(image.height*ImgW)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
} else{
if(image.height>ImgH){
ImgD.height=ImgH;
ImgD.width=(image.width*ImgH)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}

</script>

图片引用:

<img src="<%=Picfilepath%>" width="140" height="140" onload="zoomimg(this,140,140)"》
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: