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

Example 14.8:
Writing to a Window and Changing Focus


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("window.htm","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.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