This script is typically best for pop-up windows where you want to display random images on request. It will allow browser window to auto-fit according to the image size.
Add this script into head section of web page:
We just wrote a function named as resize. Call this function in the body tag of the popup page.
This function will serve the purpose and on page load it will look for the image size and will resize the browser window according to the image size.
This script is for popup page at which image is placed. Call the popup page with no toolbar or menubar as decsribed below:
<a href="#" onClick="window.open('popup-page.html', '', 'toolbar=0,menubar=0,location=0,left=0,top=113,screenX=0,screenY=100,scrollbars=yes'); return false;">Launch popup</a>