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

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

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

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

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


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.