下一个比较好。
复制代码代码如下所示:
功能formatimg2(内容)
昏暗的重
集重=新的正则表达式
re.ignorecase =真
重复全局=真的
RE(脚本)。
内容= re.replace(内容,脚本)
再次,模式= } src(= |)(。{ ^ > } *)
内容= re.replace(内容,)
设置否
formatimg =内容
端功能
图片中没有宽度和高度,这有点不好。
复制代码代码如下所示:
功能getphoto(strhtml)
昏暗的objregexp,火柴,火柴
集objregexp = new RegExp
objregexp.ignorecase =真
ObjRegExp。全球=真
ObjRegExp模式= 。
TP
集比赛= objregexp执行(strhtml)。
每场比赛的每场比赛
TP,TP match.value
退出
下一个
getphoto = TP
集objregexp =没有
端功能
下面的代码与图片成比例
复制代码代码如下所示:
功能resizeimage(imageid,limitwidth,limitheight)
{
新图像();
image.src = imageid.src;
如果(image.width <= 0 image.height <= 0回);
如果(图像宽度/ image.height = limitwidth / limitheight)
{
如果(image.width > limitwidth)
{
imageid.width = limitwidth;
imageid.height =(图像。高度×limitwidth) / image.width;
}
}
如果(image.height > limitheight)
{
imageid.height = limitheight;
imageid.width =(图像宽度* limitheight) / image.height;
}
如果(imageid.parentelement.tagname!= )
{
imageid.onclick =函数(){ window.open(这个,SRC);}
imageid.style.cursor =手;
}
}
在window.onload = initimages;
initimages()函数
{
图片/约束的宽度和高度
VaR最大= 100;
VaR最大高度= 100;
VaR IMGS = document.getelementsbytagname(IMG);
对于(var i = 0;i < imgs.length;i++)
{
VaR img = IMGS;
如果(img maxwidth |。宽度> | IMG。高>最大高度)
resizeimage(img maxwidth,最大高度);
}
}