图片等比例显示
js代碼:
?
function pimsize(imgname,widths,heights){
var w;
var h;
//window.alert(picimg.width);
//window.alert(picimg.height);
w=imgname.width;
h=imgname.height;
if(imgname.width>widths){
do
w=w-1;
while (w>widths) ;
s=w/imgname.width;
//window.alert(s);
imgname.width=w;
imgname.height=h*s;
h=imgname.height
}
//window.alert(imgname.height);
//window.alert(heights);
if(imgname.height>heights){
do
h=h-1;
while (h>heights) ;
s=h/imgname.height;
//window.alert(s);
imgname.width=w*s;
imgname.height=heights;
}
}
?
html:
<img src="UpFiles/Product/2009522125252.jpg" id="pbigpic" border="0" align="absmiddle" οnlοad="pimsize(this,320,310);" />
?
注:
asp.net 要在.cs文件這樣寫
this.pbigpic.Attributes.Add("onload", "pimsize(this,320,310);");
否則,生成失敗.
轉載于:https://www.cnblogs.com/binny1983/archive/2009/05/22/1487288.html
總結
- 上一篇: 狗窝里的小日子- 3 ...
- 下一篇: js中的Map对象