Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q686 Is is possible to load an image into a popup window and then resize the window to fit the image, even if the window is already open?

irt.org | Knowledge Base | JavaScript | Window | Q686 [ previous next ]

Q686 Is is possible to load an image into a popup window and then resize the window to fit the image, even if the window is already open?

In Netscape Navigator 4 and Internet Explorer 4 you can resize the window to match the image loaded:

<SCRIPT LANGUAGE="JavaScript"><!--
function resizeWindow() {
    if (document.images) {
        if (windowHandle.document.images.length == 1) {
            if (document.layers) windowHandle.resizeTo(windowHandle.document.images[0].width+20,windowHandle.document.images[0].height+20)
            else if (document.all) windowHandle.resizeTo(windowHandle.document.images[0].width+30,windowHandle.document.images[0].height+50)
        }
        else 
            setTimeout('resizeWindow()',1000);
    }
}


//--></SCRIPT>

<FORM>

<INPUT TYPE="BUTTON" VALUE="Image1" onClick="windowHandle = window.open('image1.gif','windowName','width=100,height=200,resizable=yes');setTimeout('resizeWindow()',2000)">
<INPUT TYPE="BUTTON" VALUE="Image2" onClick="windowHandle = window.open('image2.gif','windowName','width=200,height=200,resizable=yes');setTimeout('resizeWindow()',2000)">

</FORM>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.