Writing to a window
Question: How do I write script-generated content to another window?
Answer: To write script-generated content to another window, use the method
is the window reference, as returned by the
To make sure that your script's output actually shows up in the other window, use
after writing the content. As an example, consider the following function that opens a new window with the title Console and writes the specified
to the new window. ' ) top.consoleRef.document.close() } //-->
If you try the above example in Internet Explorer or Firefox, you might notice that after you write something to the console several times, the console window will allow you to navigate back and forth in the output's history. This is not always a desired feature. If you would like to output the new content without creating a new history entry, add the following operator after opening the window (and before the first write):
is the window reference returned by the
is a global variable in which the script stores the reference to your new document.
Note: Some browsers, e.g. Google Chrome or Safari, won't allow the back/forward navigation in the secondary window in this example, with or without