dom/tests/js/write2.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/js/write2.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +<HTML>
     1.5 +<HEAD>
     1.6 +<SCRIPT>
     1.7 +var w = null;
     1.8 +var count = 0;
     1.9 +var isOpen = false;
    1.10 +
    1.11 +function newWin() {
    1.12 +  if ((w == null) || (w.closed == true)) {
    1.13 +    w = window.open("about:blank", "writetest");
    1.14 +  }
    1.15 +}
    1.16 +
    1.17 +function incrWrite() {
    1.18 +  if (w != null) {
    1.19 +    if (!isOpen) {
    1.20 +      count = 0;
    1.21 +      isOpen = true;
    1.22 +      w.document.write("<p>Opening document and counting up....</p>");
    1.23 +    }
    1.24 +
    1.25 +    w.document.write("<p>Counter at: " + count++ + "</p>");
    1.26 +  }
    1.27 +}
    1.28 +
    1.29 +function closeDoc() {
    1.30 +  if ((w != null) && isOpen) {
    1.31 +    w.document.write("<p>Closing document!</p>");
    1.32 +    w.document.close();
    1.33 +    isOpen = false;
    1.34 +  }
    1.35 +}
    1.36 +</SCRIPT>
    1.37 +</HEAD>
    1.38 +<BODY>
    1.39 +<h1>document.write (out-of-line) test</h1>
    1.40 +<p>This test uses the open, write and close methods of a
    1.41 +document to construct a document. It tests the "out-of-line"
    1.42 +capabilities of document.write i.e. the ability to use 
    1.43 +document.write to create an entirely new document.</p>
    1.44 +
    1.45 +<form>
    1.46 +<p>Use this button to create a new window. If one already
    1.47 +exists, we'll use it.
    1.48 +<INPUT TYPE="button" NAME="newwin" VALUE="New Window" onClick="newWin(); return true;">
    1.49 +</p>
    1.50 +
    1.51 +<p>Use this button to write the new value of a counter into
    1.52 +the document. If the document was previously closed, it will be
    1.53 +reopened (and the old contents will be destroyed.
    1.54 +<INPUT TYPE="button" NAME="incrwrite" VALUE="Write" onClick="incrWrite(); return true;">
    1.55 +</p>
    1.56 +
    1.57 +<p>Use this button to close the document. Subsequent writes will rewrite
    1.58 +the document.
    1.59 +<INPUT TYPE="button" NAME="closedoc" VALUE="Close Document" onClick="closeDoc(); return true;">
    1.60 +<p>
    1.61 +</FORM>
    1.62 +</BODY>
    1.63 +</HTML>
    1.64 \ No newline at end of file

mercurial