Writing to a window

JavaScript FAQ | JavaScript Windows FAQ  

Question: How do I write script-generated content to another window?

Answer: To write script-generated content to another window, use the method

winRef.document.write() 
or
winRef.document.writeln()
, where
winRef
is the window reference, as returned by the
window.open() 
method.

To make sure that your script's output actually shows up in the other window, use

winRef.document.close()
after writing the content. As an example, consider the following function that opens a new window with the title Console and writes the specified
content
to the new window.