HTML and CSS Reference
In-Depth Information
deGradinG GraceFuLLy
Although JavaScript is enabled on the vast majority of browsers by default, it is possible for users
to disable the functionality. Typically, users resort to this action to stop unwanted pop-up ads or to
prevent what they fear is unsolicited intrusions. For whatever reason, it is a fact of life on the Web
that you can depend on a certain percentage of users having JavaScript turned off.
So what happens when such users encounter a page with JavaScript functionality? If no additional
steps beyond the JavaScript coding are taken, the page — or the functionality, at least — will simply
not work without explanation. Most designers feel that it is important to let users know that they
are missing some intended interaction, which could be quickly restored if they enabled JavaScript.
The <noscript> tag is used to provide such alternative messaging.
Typically, the <noscript> tag is placed in the <body> immediately following the JavaScript-injected
content. The following example takes an earlier example where the <script> tag was placed in the
document <body> and adds an appropriate <noscript> tag:
<h1>Today is
<script type=”text/javascript”>
<!--
document.write(Date())
-->
</script>
<noscript>
Unavailable because JavaScript is disabled on your computer. Please enable
JavaScript and refresh this page to see the current date and time.
</noscript>
</h1>
As you can see from Figure 21-5, you can seamlessly integrate the alternative text from a
<noscript> tag into the flow of your content.
FiGure 21-5
Search WWH ::




Custom Search