最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2008年03月06日 10:19:14   作者:  
下面的代碼是從html中正則取出圖片,然后批量替換等
下面這個是比較不錯的一個
復制代碼 代碼如下:

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

上面有點不好的就是對于圖片中的寬度和高度都不存在了
復制代碼 代碼如下:

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

下面的代碼時進行圖片按比例縮放
復制代碼 代碼如下:

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;      
    } 

    if (imageid.parentElement.tagName != "A") 
    { 
        imageid.onclick = function(){window.open(this.src);} 
        imageid.style.cursor = "hand"; 
    } 


window.onload = InitImages;
function InitImages() 

//圖片的約束寬度和高度
   var maxWidth = 100; 
    var maxHeight = 100; 
    var imgs = document.getElementsByTagName("img"); 
    for(var i=0; i < imgs.length; i++) 
    { 
        var img = imgs; 
        if(img.width>maxWidth||img.height>maxHeight) 
            ResizeImage(img, maxWidth, maxHeight); 
    } 
}

相關文章

最新評論

肥东县| 镇巴县| 南宫市| 叶城县| 阜阳市| 衡南县| 阿拉善盟| 辉县市| 丹棱县| 丁青县| 巴林右旗| 黑水县| 漯河市| 洪湖市| 益阳市| 长寿区| 温州市| 拜泉县| 兴和县| 靖西县| 沐川县| 浦东新区| 铁力市| 梨树县| 黄大仙区| 许昌县| 江都市| 贵港市| 芦溪县| 那曲县| 安福县| 油尖旺区| 商城县| 临城县| 乐安县| 永年县| 郯城县| 偏关县| 锡林浩特市| 聊城市| 西昌市|