Previous Example-|-Next Example-|-Return to Chapter Listing

Example 14.11:
Closing the Document Stream


Click on these buttons to open a window, then to write HTML to it:

Note that this script uses the focus() method to bring the secondary window back again. If you don't have the Atlas Preview Release 2 (Navigator 3.0 beta 3) or later this feature won't work and you'll have to switch to the window manually the second time you write to it.

Click here to close the other window:


This is the script we used. In the HEAD... <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- function OpenWindow() { Win1 = open("","SecWin","scrollbars=yes,width=400,height=230"); var sText = "<BODY>This is some text<P></BODY>" Win1.document.write("<H2>Secondary window</H2><HR><P>" + sText) } function CloseWindow() { Win1.close() } function MoreText() { Win1.focus() Win1.document.open() Win1.document.write("Some guy hit my fender the other day, and I said unto him, \"Be fruitful, and multiply.\" But not in those words.<P>Woody Allen") Win1.document.close() } //--> </SCRIPT> Then these buttons... <FORM> <input type="button" value="Open Window" onclick="OpenWindow()"> <input type="button" value="Write to Window Again" onclick="MoreText()"><P> <I>Click here to close the other window:</I><P> <input type="button" value="Close Window" onclick="CloseWindow()"> </FORM>
Previous Example-|-Next Example-|-Return to Chapter Listing