Skip to content
Permalink
Browse files

[e] (0) <noscript> example

git-svn-id: http://svn.whatwg.org/webapps@3793 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Sep 10, 2009
1 parent 754c281 commit 6a85245a2f3819276bcbf1ef9bf9ba9843382359
Showing with 64 additions and 0 deletions.
  1. +32 −0 index
  2. +32 −0 source
32 index

</div>

<div class=example>

<p>In the following example, a <code><a href=#the-noscript-element>noscript</a></code> element is
used to provide fallback for a script.</p>

<pre>&lt;form action="calcSquare.php"&gt;
&lt;p&gt;
&lt;label for=x&gt;Number&lt;/label&gt;:
&lt;input id="x" name="x" type="number"&gt;
&lt;/p&gt;
&lt;script&gt;
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&gt;
&lt;noscript&gt;
&lt;input type=submit value="Calculate Square"&gt;
&lt;/noscript&gt;
&lt;/form&gt;</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 id=sections><span class=secno>4.4 </span>Sections</h3>
32 source

</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>

0 comments on commit 6a85245

Please sign in to comment.
You can’t perform that action at this time.