ASP regular HTML picture, to the graph auto Shrink Enlarge small _ Application Skill

Source: Internet
Author: User
Here's a better one.
Copy Code code as follows:

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= "]*src (=|) (. [^>]*) > "
Content=re.replace (Content, "Set re = Nothing
formatimg = Content
End Function

What's bad about it is that there's no width or height in the picture.
Copy Code code as follows:

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 the Match in matches
TP=TP & Match.value
Exit For
Next
Getphoto=tp
Set objRegExp = Nothing
End Function

The following code scales the picture proportionally
Copy Code code as follows:

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 ()
{
The constraint width and height of the picture
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);
}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.