国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

asp正則html的圖片,對圖自動縮放大小

2024-05-04 10:57:37
字體:
供稿:網(wǎng)友
下面這個是比較不錯的一個
復(fù)制代碼 代碼如下:

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; 

    if(image.width <= 0 && image.height <= 0) return; 

    if(image.width/image.height >= limitWidth/limitHeight) 
    { 
        if(image.width > limitWidth) 
        { 
            imageid.width = limitWidth; 
            imageid.height = (image.height*limitWidth)/image.width; 
        } 
    } 
    else if(image.height > limitHeight) 
    { 
            imageid.height = limitHeight; 
            imageid.width = (image.width*limitHeight)/image.height;      
    } 
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 永靖县| 平塘县| 石景山区| 伊吾县| 康平县| 通山县| 年辖:市辖区| 晋州市| 深州市| 紫金县| 睢宁县| 庄河市| 图木舒克市| 姜堰市| 友谊县| 醴陵市| 刚察县| 松滋市| 英德市| 依安县| 潜山县| 张家界市| 城固县| 龙陵县| 锡林郭勒盟| 公安县| 炎陵县| 普宁市| 疏勒县| 奉节县| 遂溪县| 益阳市| 阳曲县| 崇左市| 滁州市| 全南县| 济源市| 屏东县| 曲麻莱县| 黑龙江省| 达拉特旗|