当前位置: 首页IT技术 → 关于利用ASP使图片自动缩放以适合界面大小的实例代码分享

关于利用ASP使图片自动缩放以适合界面大小的实例代码分享

更多

本文将给大家分享学习的是关于利用ASP使图片自动缩放以适合界面大小的实例代码分享,希望能够给大家带来帮助或启发。

如何让图片自动缩放以适合界面大小,拿出你的Editplus,打开c_function.asp文件,找到UBBCode函数,在第417行有如下语句

If Instr(strType,"[image]")>0  And ZC_UBB_IMAGE_ENABLE Then
  '[img]
    objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
    strContent= objRegExp.Replace(strContent,"<img src=""$6"" title=""$4"" width=""$2"" height=""$3""/>")
    objRegExp.Pattern="(\[IMG=)([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
    strContent= objRegExp.Replace(strContent,"<img src=""$5"" title=""$3"" width=""$2""/>")
    objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
    strContent= objRegExp.Replace(strContent,"<img src=""$2"" title=""""/>")
  End If

  在其中加上onload='java script:if(this.width>400)this.width=400;',这里400是要让超过400的图片小于400,你可以自己设定宽度.

  下面是已经改好的

If Instr(strType,"[image]")>0  And ZC_UBB_IMAGE_ENABLE Then
  '[img]
    objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
    strContent= objRegExp.Replace(strContent,"<img onload='java script:if(this.width>400)this.width=400;' src=""$6"" title=""$4"" width=""$2"" height=""$3""/>")
    objRegExp.Pattern="(\[IMG=)([0-9]*),(.*)(\])(.+?)(\[\/IMG\])"
    strContent= objRegExp.Replace(strContent,"<img onload='java script:if(this.width>400)this.width=400;' src=""$5"" title=""$3"" width=""$2""/>")
    objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
    strContent= objRegExp.Replace(strContent,"<img onload='java script:if(this.width>400)this.width=400;' src=""$2"" title=""""/>")
  End If

热门评论
最新评论
昵称:
表情: 高兴 可 汗 我不要 害羞 好 下下下 送花 屎 亲亲
字数: 0/500 (您的评论需要经过审核才能显示)