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

Q166 Is there a way to write from a window I opened back to the one that opened it using a document.write?

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

First make sure that the original window can be referred to using opener:

<SCRIPT LANGUAGE="JavaScript"><!--
function newWindow(file,window) {
     msgWindow=open('',window,'resizable=no,width=200,height=200');
     msgWindow.location.href = file;
     if (msgWindow.opener == null) msgWindow.opener = self;
}
//--></SCRIPT>

<FORM>
<INPUT TYPE="button" VALUE="Open New Window" onClick="newWindow('a.html','window2')">
</FORM>

Then in the new window:

<SCRIPT LANGUAGE="JavaScript"><!--
opener.open();
opener.document.write('Hello World');
opener.close();
//--></SCRIPT>

Feedback on 'Q166 Is there a way to write from a window I opened back to the one that opened it using a document.write?'

©2018 Martin Webb