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

Q398 How can I with a click on a button in a window, open a new window, setup a frameset in the new window and write text to the frames, all from the same script?

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

Try something like this:

<script language="JavaScript"><!--
function createWindow() {
    mywindow = window.open('about:blank','mywindowname','width=300,height=300');
    setTimeout('createFrameset()',10);
}

function createFrameset() {
    var output = '<frameset rows="50%,*">' +
                 '<frame src="about:blank">' +
                 '<frame src="about:blank">' +
                 '<\/frameset>';
    mywindow.document.write(output);
    setTimeout('createFrames()',10);
}

function createFrames() {
    createFrame1();
    createFrame2();
}

function createFrame1() {
    mywindow.frames[0].document.write('<h1>Hello<\/h1>');
}

function createFrame2() {
    mywindow.frames[1].document.write('<h1>World<\/h1>');
}

//--></script>

<form>
<input type="button" onClick="createWindow()" value="create popup frameset">
</form>

Feedback on 'Q398 How can I with a click on a button in a window, open a new window, setup a frameset in the new window and write text to the frames, all from the same script?'

©2018 Martin Webb