Function FormatImg2(content) dim re Set re=new RegExp re.IgnoreCase =true re.Global=True re.Pattern="(script)" Content=re.Replace(Content,"script") re.Pattern="<img.[^>]*src(=| )(.[^>]*)>" Content=re.replace(Content,"<img src=$2 style=""cursor: pointer"" alt=""點此在新窗口瀏覽圖片"" onclick=""javascript:window.open(this.src);"" onload=""javascript:resizepic(this)"" border=""0""/>") set re = nothing FormatImg = content end function
上面有點不好的就是對于圖片中的寬度和高度都不存在了
復(fù)制代碼 代碼如下:
Function getphoto(strHTML) Dim objRegExp, Match, Matches Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<img.+?>" tp="" Set Matches = objRegExp.Execute(strHTML) For Each Match in Matches tp=tp & Match.value exit for Next getphoto=tp Set objRegExp = Nothing End Function
下面的代碼時進(jìn)行圖片按比例縮放
復(fù)制代碼 代碼如下:
function ResizeImage(imageid,limitWidth,limitHeight) { var image = new Image(); image.src = imageid.src;