Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

You are here: irt.org | FAQ | JavaScript | Window | Q686 [ previous next ]

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>

©2018 Martin Webb