UBB如何添加控制图片大小
来源:百度知道 编辑:UC知道 时间:2024/07/05 01:04:56
UBB.ASP
'图片UBB
re.pattern="\[img\](http|https|ftp):\/\/(.[^\[]*)\[\/img\]"
strcontent=re.replace(strcontent,"<a onfocus=""this.blur()"" href=""$1://$2"" target=new><img class=""futu"" src=""$1://$2"" border=""0"" alt=""按此在新窗口浏览图片"" ></a>")
这样[img]http://www.www.ww/1.gif[/img]形式的可以显示图片
但是[img=xxx,xxx]http://www.www.ww/1.gif[/img]形式的却不能显示图片
我想再添加2个变量,来控制高和宽,可试了半天没成功,应该怎么添加?
'图片UBB
re.pattern="\[img\](http|https|ftp):\/\/(.[^\[]*)\[\/img\]"
strcontent=re.replace(strcontent,"<a onfocus=""this.blur()"" href=""$1://$2"" target=new><img class=""futu"" src=""$1://$2"" border=""0"" alt=""按此在新窗口浏览图片"" ></a>")
这样[img]http://www.www.ww/1.gif[/img]形式的可以显示图片
但是[img=xxx,xxx]http://www.www.ww/1.gif[/img]形式的却不能显示图片
我想再添加2个变量,来控制高和宽,可试了半天没成功,应该怎么添加?
大多数人要实现图片缩放,都是在<img>里添加onload事件。
W3C Xhtml1.0 标准里,<img>没有onload,所以凡是在<IMG>里添加ONLOAD事件的,将不能通过XHTML验证。
可以使用单独的JS函数,在<BODY>的ONLOAD里调用,来实现图片缩放。
JS代码:
function imgfixlen()
{
obj=document.getElementsByTagName("img");
for(i=0;i<obj.length;i++)
{
if(obj[i].className=="futu")
{
if(obj[i].width>400) obj[i].width=400;
if(obj[i].height>200) obj[i].height=200;
}
}
}
Html代码:
<body onload="imgfixlen()">
Img标记:
<img src="图片URL" alt="图片说明" class="futu" />
记得在UBB代码的[IMG]正则表达式中,加上class="futu"