最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp正则html的图片,对图自动缩放大小
时间:2022-07-02 23:21:34 编辑:袖梨 来源:一聚教程网
下面的代码是从html中正则取出图片,
Function getphoto(strHTML) 
Dim objRegExp, Match, Matches 
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True 
objRegExp.Global = True 
objRegExp.Pattern = "
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 max; 
    var max; 
     
    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); 
    } 
}
相关文章
- 暗喻幻想布丽吉塔设施完工时间说明 10-31
- 三国志8重制版居民情感作用介绍说明 10-31
- 三国志8重制版游戏灾害效果介绍说明 10-31
- 三国志8重制版武将不同状态区别说明 10-31
- 三国志8重制版武将阶级提升方法分享 10-31
- 三国志8重制版武将不同阶级作用说明 10-31
 
             
                                 
                                 
                                 
                                 
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                        