复制代码代码如下所示:
图像大小
正确 resizeimages()
函数 {
VaR My IMG,oldwidth,oldheight;
VaR最大= 550;
VaR最大高度= 880
VaR IMGS = document.getelementbyid('article)。GetElementsByTagName('img '); / /如果你确定不是文章,请在这里换
为(i = 0;i < imgs.length;i++){
My IMG = IMGS {我};
如果(myimg.width > My IMG。高度)
{
如果(myimg.width > maxwidth)
{
oldwidth = myimg.width;
myimg.height = myimg.height *(最大/ oldwidth);
myimg.width =最大;
}
其他{ }
如果(myimg.height >最大高度)
{
oldheight = myimg.height;
myimg.width = myimg.width *(最大高度/ oldheight);
myimg.height =最大高度;
}
}
}
}
图像大小正确
resizeimages();
它是指在指定
区域控制图片的大小,或者一些较大的
广告图像会变形。
使用图片来控制代码:
复制代码代码如下所示:
功能controlimg(ELE,W,H){
var c = ele.getelementsbytagname(IMG);
对于(var i = 0;i < c.length;i++){
VaR W0 = C {我}。clientwidth,H0 = C {我自己};
VaR T1 = W0 / W,T2 = H0 / H;
如果(T1>1 | | T2 > 1 | | W0 > = 600){
C {我},宽度= math.floor(W0 /(T1 > t2t1:T2));
C {我}。高度= math.floor(H0 /(T1、T2 t2t1:));
如果(
文件all){
C {我}。outerhtml =+ C {我} outerHTML +。
}
别的{
在新建窗口中打开图片;
C {我}。onclick=功能(e){ window.open(这个,SRC)}
}
}
}
}
元素是指定的区域,w是最大的宽度,比这个小,h是最大的高度。