有谁知道ASP图片显示的问题
来源:百度知道 编辑:UC知道 时间:2024/07/02 14:57:27
我想说的是,先提取宽高,再按比例缩放
你其实根本不用管你的图片有多大,你要注意的是你排版的页面,框架内可以显示多大的图片.
可以固定图片的宽或者高,这里以固定宽为例
<img src="001.jpg" onload="if(this.width>100){this.width=100;}">
图片加载的时候,为以宽100为标准,自动按例缩小
<img src="001.jpg" onload="this.width=this.width/2">
<scriptlanguage="javascript">//图片按比例缩放,可输入参数设定初始大小functionresizeimg(ImgD,iwidth,iheight) {varimage=newImage();
image.src=ImgD.src;if(image.width>0 && image.height>0){if(image.width/image.height>= iwidth/iheight){if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}else{if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt