文章探索:   分类:    关键字:  
  + 栏目导航
  + 相关文章
document 对象
Window.Open详解
JS replace 方法
JScript 属性
JScript 对象
JScript 方法
关于window.opener的用法
JavaScript语法——style.display 属..
不被拦截的弹出窗口代码
showModalDialog和showModelessDialog..
showModelessDialog()使用详解
IE中非模式对话框(showModelessDialog..
JS eval()函数
Preferences 指南
JS中的setTimeout和setInterval的区别
JavaScript对象与数组参考大全
javascript动态增加、删除、填充表格..
用Java实现几种常见的排序算法
JavaScript 日期函数
JavaScript 使用字符串函数
如何用Javascript获得TextArea中的光..
Document 对象方法
在input中只能输入数字
selection.createRange() 用法例子
获取网页各种宽高的值
JavaScript方法 - indexOf方法
substring函数详解
40种网页常用小技巧(javascript)
event.X和event.clientX有什么区别
clientX, clientY,offsetX, offsetY,..


技术教程 -> JavaScript教程 ->  
如何让图片自动缩放以适合界面大小
来源:http://www.webjx.com   人气:682   录入时间:2007-11-8
    如何让图片自动缩放以适合界面大小,拿出你的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"" 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
   
   
   注意:只有使用了UBB标签[IMG]的才可以实现自动缩放
   




Copyright(C)2007-2024 广州市佳沛数码科技有限公司 版权所有
公司地址: 广州市荔湾区东漖北路560号511室
电话:020-81803473 传真:020-81544987