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

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?

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

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?

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?'


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.