Images of the actual size are displayed on the new page.

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Script language = "JavaScript" type = "text/JavaScript">
<! --
Var imgObj;
Function checkImg (theURL, winName ){
If (typeof (imgObj) = "object "){
// Whether the image height and width have been obtained
If (imgObj. width! = 0) & (imgObj. height! = 0 ))
// Set the height and width of the pop-up window based on the obtained image height and width, and open the window
// Increment 20 and 30 indicate the interval between the window border and the image.
OpenFullSizeWindow (theURL, winName, ", width =" + (imgObj. width + 20) + ", height =" + (imgObj. height + 30 ));
Else
// Because the Image is dynamically loaded through the Image object, it is impossible to get the Image width and height immediately, so the check is repeated every 100 milliseconds.
SetTimeout ("checkImg ('" + theURL + "', '" + winName + "')", 100)
}
}

Function OpenFullSizeWindow (theURL, winName, features ){
Var aNewWin, sBaseCmd;
// Display parameters
SBaseCmd = "toolbar = no, location = no, status = no, menubar = no, scrollbars = no, resizable = no ,";
// Whether the call is from checkImg
If (features = null | features = ""){
// Create an image object
ImgObj = new Image ();
// Set the image source
ImgObj. src = theURL;
// Start to get the image size
CheckImg (theURL, winName)
}
Else {
// Open the window
ANewWin = window. open (theURL, winName, sBaseCmd + features );
// Focus window
ANewWin. focus ();
}
}
// -->
</Script>


In use, place the above Code in the

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.