Back to the original French page Read this page in Italian by Google Translation Read this page in Portuguese by Google Translation Read this page in English by Google Translation Read this page in German by Google Translation Read this page in Spanish by Google Translation Read this page in Arabic by Google Translation Read this page in Hebrew by Google Translation

JavaScript and Accessibility: Introduction

Go to top of content without using bar access and sharing Instructions to bar access and sharing Listen to the main content of this page
Print Print the main content of this page Send Email the main content of this page Share Share this page on Mixx Share this page on Facebook Share this page on Wikio Share this page on Google Share this page on LinkedIn Share this page on Digg Share this page on del.icio.us Share this page on Netvibes

Warning: The original version of this document is Creating Accessible JavaScript: Overview . The French translation was done by ideos under an agreement between WebAIM and ideos .

Note: see page Documents on Web accessibility for a list of all the documents already translated. Other resources on web accessibility are also listed in the Portal of digital access .

Overview of JavaScript

a ramp for wheelchair with the word 'javascript' written on it It may be preferable to define what is NOT JavaScript. First, the JavaScript does not use HTML tags do not depend on general rules of HTML. However, you can use JavaScript with HTML on a Web page. Second, the JavaScript is not Java. Although JavaScript is often called Java, the two are different. Java was developed by Sun Microsystems and is a complete programming language. For its part, JavaScript was developed by Netscape Corporation. Although similar to Java syntax, JavaScript is a programming language independent. For the JavaScript function, it must be part of a Web page that is displayed in a browser that understands JavaScript. The Java programming language from Sun can be implemented in Web pages as an internal program, while JavaScript depend on the computer of the client (visitor) to work.

Once again, the JavaScript is not HTML or an HTML version. It is a separate scripting language. HTML is read and processed by the web browser. When the browser reads the JavaScript code in your HTML document, it executes the code, then displays all output inside the webpage. To read the JavaScript, the computer must have a JavaScript interpreter, a program that interprets and executes the script and the interpreter must be enabled.

When used alone, the HTML can only create static pages. There is so little interaction with the user and little dynamic content within a page. HTML can not "think", it lacks the capacity to do mathematics, to store variables or display content dynamically. JavaScript allows your web page to "think". Although many programs on the server side scripts (such as PHP, JSP, ASP or ColdFusion) have the ability to handle such functions, JavaScript can perform these functions in the Web browser client. Because JavaScript is a scripting language, it enables developers to implement small applications in their pages. These programs can do things as simple as changing an image when the mouse hovers over or something as complicated as the execution of mathematical formulas input by the user.

The accessibility issues JavaScript

JavaScript allows developers to add more interaction, more information processing and control of web content. However, JavaScript can also create problems of accessibility. These problems include:

  • Navigation. Inability or difficulty navigating by keyboard or using assistive technology.
  • Hidden content. Presentation of content or functionality not available to assistive technologies.
  • Control by the user. Difficulty user control of automatic content changes.
  • Confusion / Disorientation. Modification or removal of original functionality of a user agent (browser) or triggering events that the user does not know.

A web page containing JavaScript is generally available if the JavaScript features are device-independent (does not work only with the mouse or the keyboard only) and information (content) is available to assistive technologies. Unfortunately, there is no easy solution to solve all the accessibility issues related to JavaScript. The only way to ensure the accessibility of JavaScript is to assess each script and design an appropriate solution to every problem encountered accessibility. Developers should familiarize themselves with issues relating to accessibility of the JavaScript and find solutions to achieve one or two of the following actions:

  1. Making JavaScript directly accessible.
  2. Provide an accessible alternative to JavaScript (not using Javascript).

The JavaScript that has no effect on accessibility

The fact that Javascript is used on a page that does not necessarily mean that the page is inaccessible. In many cases, JavaScript can be used to increase accessibility. Additional information, warnings or instructions may be provided to users through advertisements JavaScript (JavaScript prompt). For example, under Section 508 (Law United States), a user must be notified when a time limit for response is required and must have the opportunity to request more time. Such a feature would be difficult to do with HTML alone.

JavaScript is sometimes used to create the visual interface elements that have no impact on accessibility. Javascript is commonly used for image rollovers in which an image is replaced by another when the mouse is placed over the image (for example, when a navigation item changes for displaying a shadow, glow or development when the user moves the mouse over).

Place your mouse over the image below to see example JavaScript that has no effect on accessibility.

Welcome

Problems

None. In this example, any content or feature is introduced by the major Javascript. The change of image is purely decorative.

Solution

No additional technical accessibility is required. Remember to save the image a text alternative (eg <img alt="Accueil"...> ).

This use of JavaScript does not need additional accessibility feature as no important content is displayed.

To open the JavaScript is to consider the following questions. Each of them will be discussed in subsequent pages.

  • When you manage events, use only those that are independent of device (for example, those that do not use only the mouse or the keyboard only).
  • The content and functionality that are provided by scripts must be made accessible to assistive technologies.
  • Web pages that have scripts must be fully navigable with the keyboard.
  • JavaScript should not modify or supplant the original functionality of a browser if it creates confusion.
  • When the JavaScript can not be made natively accessible, affordable alternative should be given (an alternative not using Javascript).

Comparison of recommendations for JavaScript

The theme of accessibility of the script is processed by both Section 508 of the Rehabilitation Act (USA) and WCAG 1.0. They require that the content and functionality of scripts are accessible to assistive technologies such as screen readers for example. In addition, users should have control over changes in time content. But there are differences between these two documents. WCAG ask that content and functionality are available with scripting disabled and users are warned if the JavaScript changes the appearance or functionality of the browser window, while Section 508 requires only that the script that is accessible or affordable alternative is given.

Compliance testing of JavaScript

As stated above, your Web pages must be fully functional with JavaScript disabled. This is necessary under the WCAG 1.0 Priority 1. Section 508 does not require that the page works if JavaScript is disabled, but calls the scripts themselves are available natively. This tutorial teaches strategies to make your SCIPT natively accessible and assumes that if you, as a developer you want to achieve a high level accessibility or to comply with WCAG, you should test your pages to make sure they work with JavaScript disabled.

Disable JavaScript

Follow instructions to disable or enable JavaScript in your browser. You can also determine if JavaScript is enabled . Test your pages with JavaScript enabled and see if the content and functionality are available. Pay attention to re-enable JavaScript when you have finished your testing.

Internet Explorer 6.X

  1. Launch Internet Explorer.
  2. Select Tools> Internet Options.
  3. In the dialog box in Internet Options, select the Security tab.
  4. Click the Custom Level button at the bottom of the window. The dialog box Security Settings opens in a new window.
  5. In the Scripting category, enable / disable Active scripting, Allow Paste Operations via script and Scripting of Java applets.
  6. Click OK two times to close the dialog box.
  7. Reload the page.

Firefox 3.x

  1. Launch Firefox.
  2. Select Tools> Options.
  3. Select the Content tab.
  4. Check / uncheck Enable JavaScript.
  5. Click OK.
  6. Reload the page.

Netscape 7.X

  1. Launch Netscape.
  2. Select Edit> Preferences.
  3. Click on the arrow next to Advanced.
  4. Click Scripts & Plugins page.
  5. Check / uncheck the Browser 'javascript enabled.
  6. Click OK.
  7. Reload the page.

Opera 7.X

  1. Start Opera.
  2. Select File> Quick Preferences.
  3. Check / uncheck Enable Javascript.
  4. Reload the page.

WebAIM is an initiative of:
Center for Persons with Disabilities (CPD) Utah State University

Copyright 1999-2009 WebAIM

Top