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

Example 15.13:
Opening 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. This is a JavaScript 1.1 feature, so you'll need Navigator 3 or later; with an earlier browser 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") } //--> </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