HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
3856Elaborate on <noscript> example.2009-09-15 08:22
@@ -13418,23 +13418,21 @@ not-slash     = %x0000-002E / %x0030-10FFFF
     </ol>
 
    </dd>
 
   </dl>
 
   <p class="note">All these contortions are required because, for
   historical reasons, the <code>noscript</code> element is handled
   differently by the <span>HTML parser</span> based on whether <span
   title="scripting flag">scripting was enabled or not</span> when the
-  parser was invoked. The element is not allowed in XML, because in
-  XML the parser is not affected by such state, and thus the element
-  would not have the desired effect.</p>
+  parser was invoked.</p>
 
   <p>The <code>noscript</code> element must not be used in <span>XML
   documents</span>.</p>
 
   <p class="note"><strong>The <code>noscript</code> element is only
   effective in the <span>the HTML syntax</span>, it has no effect in
   the <span>the XHTML syntax</span>.</strong></p>
 
   <div class="impl">
 
@@ -13465,24 +13463,57 @@ not-slash     = %x0000-002E / %x0030-10FFFF
   x.oninput = function () {
     var v = x.valueAsNumber;
     output.textContent = v + ' squared is ' + v * v;
   };
  &lt;/script>
  &lt;noscript>
   &lt;input type=submit value="Calculate Square">
  &lt;/noscript>
 &lt;/form></pre>
 
-   <p>When script is enabled, a button appears to do the calculation
+   <p>When script is disabled, a button appears to do the calculation
    on the server side. When script is enabled, the value is computed
    on-the-fly instead.</p>
 
+   <p>The <code>noscript</code> element is a blunt
+   instrument. Sometimes, scripts might be enabled, but for some
+   reason the page's script might fail. For this reason, it's
+   generally better to avoid using <code>noscript</code>, and to
+   instead design the script to change the page from being a
+   scriptless page to a scripted page on the fly, as in the next
+   example:</p>
+
+   <pre>&lt;form action="calcSquare.php">
+ &lt;p>
+  &lt;label for=x>Number&lt;/label>:
+  &lt;input id="x" name="x" type="number">
+ &lt;/p>
+ <strong>&lt;input id="submit" type=submit value="Calculate Square"></strong>
+ &lt;script>
+  var x = document.getElementById('x');
+  var output = document.createElement('p');
+  output.textContent = 'Type a number; it will be squared right then!';
+  x.form.appendChild(output);
+  x.form.onsubmit = function () { return false; }
+  x.oninput = function () {
+    var v = x.valueAsNumber;
+    output.textContent = v + ' squared is ' + v * v;
+  };
+<strong>  var submit = document.getElementById('submit');
+  submit.parentNode.removeChild(submit);</strong>
+ &lt;/script>
+&lt;/form></pre>
+
+   <p>The above technique is also useful in XHTML, since
+   <code>noscript</code> is not supported in <span>the XHTML
+   syntax</span>.</p>
+
   </div>
 
 
 
   <h3>Sections</h3>
 
   <h4>The <dfn><code>body</code></dfn> element</h4>
 
   <dl class="element">
    <dt>Categories</dt>

|