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