|
1 <HTML> |
|
2 <HEAD> |
|
3 <SCRIPT> |
|
4 var w = null; |
|
5 var count = 0; |
|
6 var isOpen = false; |
|
7 |
|
8 function newWin() { |
|
9 if ((w == null) || (w.closed == true)) { |
|
10 w = window.open("about:blank", "writetest"); |
|
11 } |
|
12 } |
|
13 |
|
14 function incrWrite() { |
|
15 if (w != null) { |
|
16 if (!isOpen) { |
|
17 count = 0; |
|
18 isOpen = true; |
|
19 w.document.write("<p>Opening document and counting up....</p>"); |
|
20 } |
|
21 |
|
22 w.document.write("<p>Counter at: " + count++ + "</p>"); |
|
23 } |
|
24 } |
|
25 |
|
26 function closeDoc() { |
|
27 if ((w != null) && isOpen) { |
|
28 w.document.write("<p>Closing document!</p>"); |
|
29 w.document.close(); |
|
30 isOpen = false; |
|
31 } |
|
32 } |
|
33 </SCRIPT> |
|
34 </HEAD> |
|
35 <BODY> |
|
36 <h1>document.write (out-of-line) test</h1> |
|
37 <p>This test uses the open, write and close methods of a |
|
38 document to construct a document. It tests the "out-of-line" |
|
39 capabilities of document.write i.e. the ability to use |
|
40 document.write to create an entirely new document.</p> |
|
41 |
|
42 <form> |
|
43 <p>Use this button to create a new window. If one already |
|
44 exists, we'll use it. |
|
45 <INPUT TYPE="button" NAME="newwin" VALUE="New Window" onClick="newWin(); return true;"> |
|
46 </p> |
|
47 |
|
48 <p>Use this button to write the new value of a counter into |
|
49 the document. If the document was previously closed, it will be |
|
50 reopened (and the old contents will be destroyed. |
|
51 <INPUT TYPE="button" NAME="incrwrite" VALUE="Write" onClick="incrWrite(); return true;"> |
|
52 </p> |
|
53 |
|
54 <p>Use this button to close the document. Subsequent writes will rewrite |
|
55 the document. |
|
56 <INPUT TYPE="button" NAME="closedoc" VALUE="Close Document" onClick="closeDoc(); return true;"> |
|
57 <p> |
|
58 </FORM> |
|
59 </BODY> |
|
60 </HTML> |