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

Example 14.12:
Clearing the Window

Click here to clear the window (the clear() function isn't working correctly right now, so we're writing a blank document to clear 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 after clearing it.

Click here to reopen the 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 ClearWindow() { Win1.focus() Win1.document.write() Win1.document.close() } //--> </SCRIPT> Then these buttons... <FORM> <input type="button" value="Clear the Window" onclick="ClearWindow()"><P> <input type="button" value="Close the Window" onclick="CloseWindow()"><P> <I>Click here to reopen the window:</I><BR> <input type="button" value="Reopen Window" onclick="OpenWindow()"> </FORM>
Previous Example-|-Next Example-|-Return to Chapter Listing