Section 13.7. Accessibility


13.7. Accessibility

The Web is a wonderful tool for disseminating information, and JavaScript programs can enhance access to that information. JavaScript programmers must be careful, however: it is easy to write JavaScript code that inadvertently denies information to visitors with visual or physical handicaps.

Blind users may use a form of "assistive technology" known as a screen reader to convert written words to spoken words. Some screen readers are JavaScript-aware, and others work best when JavaScript is turned off. If you design a web site that requires JavaScript to display its information, you exclude the users of these screen readers. (And you have also excluded anyone who browses with a mobile device, such as a cell phone, that does not have JavaScript support, as well as anyone else who intentionally disables JavaScript in his browser.) The proper role of JavaScript is to enhance the presentation of information, not to take over the presentation of that information. A cardinal rule of JavaScript accessibility is to design your code so that the web page on which it is used will still function (at least in some form) with the JavaScript interpreter turned off.

Another important accessibility concern is for users who can use the keyboard but cannot use (or choose not to use) a pointing device such as a mouse. If you write JavaScript code that relies on mouse-specific events, you exclude users who do not use the mouse. Web browsers allow keyboard traversal and activation of a web page, and your JavaScript code should as well. And at the same time, you should not write code that requires keyboard input either, or you will exclude users who cannot use a keyboard as well as many users of tablet PCs and cell phone browsers. As shown in Chapter 17, JavaScript supports device-independent events, such as onfocus and onchange, as well as device-dependent events, such as onmouseover and onmousedown. For accessibility, you should favor the device-independent events whenever possible.

Creating accessible web pages is a nontrivial problem without clear-cut solutions. At the time of this writing, debate continues on how to best use JavaScript to foster, rather than degrade, accessibility. A full discussion of JavaScript and accessibility is beyond the scope of this book. An Internet search will yield a lot of information on this topic, much of it couched in the form of recommendations from authoritative sources. Keep in mind that both client-side JavaScript programming practices and assistive technologies are evolving, and accessibility guidelines do not always keep up.




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net