Asp学习站欢迎你!

ASP程序实现图片自动缩放以适合界面大小

来源:ASP学习网 作者:Admin 时间:08-06-24 点击:

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

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"" 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,你可以自己设定宽度.

下面是已经改好的

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='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


 

  
标签: 错误】 【打印】 【关闭
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 验证码: 验证码 查看所有评论