如何让图片自动缩放以适合界面大小,拿出你的editplus,打开c_function.asp文件,找到ubbcode函数,在第417行有如下语句
objregexp.pattern=”(\[img=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/img\])”
strcontent= objregexp.replace(strcontent,”<img src=””$6″” alt=””$4″” title=””$4″” width=””$2″” height=””$3″”/>”)
objregexp.pattern=”(\[img=)([0-9]*),(.*)(\])(.+?)(\[\/img\])”
strcontent= objregexp.replace(strcontent,”<img src=””$5″” alt=””$3″” title=””$3″” width=””$2″”/>”)
objregexp.pattern=”(\[img\])(.+?)(\[\/img\])”
strcontent= objregexp.replace(strcontent,”<img src=””$2″” alt=”””” title=””””/>”)
end if
在其中加上onload=javascript:if(this.width>400)this.width=400;,这里400是要让超过400的图片小于400,你可以自己设定宽度.
下面是已经改好的
objregexp.pattern=”(\[img=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/img\])”
strcontent= objregexp.replace(strcontent,”<img onload=javascript:if(this.width>400)this.width=400; src=””$6″” alt=””$4″” title=””$4″” width=””$2″” height=””$3″”/>”)
objregexp.pattern=”(\[img=)([0-9]*),(.*)(\])(.+?)(\[\/img\])”
strcontent= objregexp.replace(strcontent,”<img onload=javascript:if(this.width>400)this.width=400; src=””$5″” alt=””$3″” title=””$3″” width=””$2″”/>”)
objregexp.pattern=”(\[img\])(.+?)(\[\/img\])”
strcontent= objregexp.replace(strcontent,”<img onload=javascript:if(this.width>400)this.width=400; src=””$2″” alt=”””” title=””””/>”)
end if