HTML and CSS Reference
In-Depth Information
Should the <script> tag be located in the <head> of the web page, you must make sure to place the
<noscript> tag where the JavaScript-driven content is expected. Here's the HTML section of the
earlier example that displayed the JavaScript calculated date when the page loaded:
<h1>The date is
unavailable because JavaScript is disabled on your computer. Please enable
JavaScript and refresh this page to see the current date and time.
<input type=”text” name=”todaysDate” id=”todaysDate” disabled=”disabled” />
Again, the <noscript> text is shown only when JavaScript is disabled.
The HTML5 specification currently makes it possible for the <noscript> tag to
be placed in the <head> of the web page as well as the <body> . No browser has,
as of this writing, implemented this functionality, however.
TesTinG JaV
Ja V
Ja V V
Testing is one of the key steps to working with any computer language, and JavaScript is no excep-
tion. Though numerous tools are available for JavaScript development, you can employ a couple of
built-in functions to debug your scripts when — not if — you run into problems with your code.
First, you want to familiarize yourself with the technique for turning off JavaScript in your browser
so you can emulate the disabled JavaScript condition. Here's how you disable JavaScript in the top
three browsers:
Internet Explorer:
Choose Tools Internet Options. When the Internet Options dialog
opens, switch to the Security tab and click Custom Levels. In the Security Settings -
Internet Zone dialog box, scroll down to the Scripting section and, under Active scripting,
click Disable. Click OK once to close the Security Settings dialog and then again to close
Internet Options.
Choose Edit Preferences on Windows or Firefox Preferences on the Mac.
When the Preferences dialog box opens, switch to the Content tab and uncheck the Enable
JavaScript option. Close the dialog box.
Choose Edit Preferences on Windows or Firefox Preferences on the Mac. In the
Preferences dialog box, switch to the Security category. Under the Web Content section,
uncheck the Enable JavaScript option and close the dialog box.
Now that you know how to test for disabled JavaScript scenarios, how do you test your page when
JavaScript is working? A very simple JavaScript function, alert() , can help you track what is going
on — and going wrong — with your code. You've seen the alert() function in action earlier: When
Search WWH ::

Custom Search