HTML and CSS Reference
In-Depth Information
play it on the page, or to submit a form for processing, all without changing
the full page in the browser. I'll discuss AJAX in detail in Lesson 16, “Using
JavaScript Libraries.” </dd>
<dt> When I use JavaScript, do I need to accommodate users whose browsers may
not support JavaScript or who have disabled it? </dt>
<dd> Some estimates indicate that over 90% of Web users have JavaScript
enabled. However, unless you have a really good reason not to, you should make
accommodations for users without JavaScript. You need not offer users who don't
have JavaScript an identical experience to those who have it, but they should be
able to access your site. For example, if you run an online store, do you really
want to shut out users because of their browser configuration? </dd>
</dl>
15
</body>
</html>
Output
.
FIGURE 15.4
The FAQ page.
The page is designed so that it works perfectly well without JavaScript; all the questions
and answers are displayed so that the user can read them. This is what unobtrusive
JavaScript is all about.
Adding the Script After the page has been created and you've confirmed that it's
working correctly, the next step is to add JavaScript into the mix. To include the script on
the page, I just need to add the link to the external script to the header:
<script type=”text/javascript” src=”faq.js”></script>
That <script> tag loads and execute the script in the file faq.js . After the JavaScript
has been added, the answers to the questions are hidden, as shown in Figure 15.5.
Search WWH ::




Custom Search