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

Example 14.9:
Clearing the Web Page Before Writing to a Window


Click on these buttons to open a window, then to write HTML to it. You'll notice this time that the original Web document is cleared before the new text is written:

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("window.htm","SecWin","scrollbars=yes,width=400,height=230"); } function CloseWindow() { Win1.close() } function MoreText() { Win1.document.write("<P>Here's some <P>more text for you...and some more. Yes, and more, and yet more<BR>") Win1.focus() } //--> </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