HTML Standard Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/3793

File a bug

SVNBugCommentTime (UTC)
3793<noscript> example2009-09-10 11:17
Index: source
===================================================================
--- source	(revision 3792)
+++ source	(revision 3793)
@@ -13454,8 +13454,40 @@
 
   </div>
 
+  <div class="example">
 
+   <p>In the following example, a <code>noscript</code> element is
+   used to provide fallback for a script.</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>
+ &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;
+  };
+ &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
+   on the server side. When script is enabled, the value is computed
+   on-the-fly instead.</p>
+
+  </div>
+
+
+
   <h3>Sections</h3>
 
   <h4>The <dfn><code>body</code></dfn> element</h4>

|