document.open() document.write("Hello There") document.close() |
When I create a new window, I am also opening a new document. So I can write to a new window with this series of commands.
NewWindow = window.open("","","width=200,height=200") NewWindow.document.write("Hello There") NewWindow.document.close() |
The document.write() method can contain either text or a variable inside the perentheses. The following example creates a variable, then writes the variable to a new document.
SampleText = "Hello there, " + "It's nice to see you again."
NewWindow = window.open("","","width=200,height=200") |
I can even include HTML tags in the document.write() statement. Like this:
NewWindow = window.open("","","width=200,height=200") NewWindow.document.write("<CENTER><H1>Hello there</H1></CENTER>") NewWindow.document.close() |