CODEDIGEST InstallShield
Home Articles CodeDigest Tutorials InstallShield FAQs
Skip Navigation LinksHome » CodeDigest » Fit Popup window Size to the Image Size using JavaScript   You are not logged in.
Search
 

Sponsors
InstallShield
 

Sponsored Links
 

Technologies
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
Fit Popup window Size to the Image Size using JavaScript
Fit Popup window Size to the Image Size using JavaScript
Submitted By Satheesh Babu
On 1/2/2009 6:41:07 AM
Tags: CodeDigest,JavaScript  

Fit Popup window Size to the Image Size using JavaScript

 

There may be requirements where we need to display the full image in a popup window when we click a thumbnail image in aspx page. By default, the popup window will display the full image with lots of white spaces on the sides of the window. To make the image to exactly fit the popup window, we need to set the popup dimension to the image dimension.

 

The following code snippet will help us to fit the popup window dimension to the image dimension using JavaScript. 

 

    <script language="javascript">

    function FitImageToWindow()

    {

    var width = document.images[0].width;

    var height = document.images[0].height;   

    window.resizeTo(width,height);

    }

   

    </script>

 

    <img src="new.jpg" onload="FitImageToWindow()" />   

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!