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

Q1159 How can I open a popup windows to fit the dynamically written contents?

You are here: irt.org | FAQ | DHTML | Q1159 [ previous next ]

Try:

<body onLoad="openWindow(1)">

<script language="JavaScript"><!--
var windowHandle = null
function openWindow(i) {
    var width=100, height=100;
    if (document.layers) {
        width = document.layers['myId' + i].document.width + 40;
        height = document.layers['myId' + i].document.height;
    }
    else if (document.all) {
        width = document.all['myId' + i].style.width + 40;
        height = document.all['myId' + i].style.height;
    }
    windowHandle = window.open('about:blank','windowName','width=' + width + ',height=' + height);
    setTimeout('updateWindow(' + i + ')',1);
}

function updateWindow(i) {
    windowHandle.document.open();
    windowHandle.document.write('How wide<br>and how<br>high is this<br>layer');
    windowHandle.document.close();
}
//--></script>

<div id="myId1" style="position:absolute; visibility: hidden;">
<script language="JavaScript"><!--
if (document.all || document.layers)
    document.write('How wide<br>and how<br>high is this<br>layer');
//--></script>
</div>

©2018 Martin Webb