dom/tests/js/write2.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial