JavaScript is a client-side scripting language used by many different web sites. JavaScript can be used to create fly-out menus, mouseovers and form validation. However JavaScript has many accessibility problems; and a text equivalent is always required.
When first developing a site, consider whether JavaScript need be used in the site at all. Many common JavaScript functions are adequately replicated in HTML and provide an enhanced level of accessibility. Some of the things that should be replaced with HTML functionality are detailed in the following table.
| Functionality | JavaScript | Equivalent HTML |
|---|---|---|
| Text link | <a href=“javascript: location.href ='page.html'”> Page</a> |
<a href=“page.html”> Page</a> |
| Opening a new window | <a href=“javascript:window.open ('page.html', '_blank')”>Page</a> |
<a href=“page.html” target=“_blank”> |
| Form submission | <a href=“javascript: this.form.submit();”> Submit</a> |
< input name=“ submit” type=“ submit” value=“ Submit”> |
When it is necessary to include JavaScript functionality within a site, it is mandatory to require a text alternative. This can be done through the NOSCRIPT element. Content within the NOSCRIPT element must be the equivalent of the content or functionality provided by the JavaScript. The site must be functional and all content available when JavaScript is disabled.
When signing up for Gmail (with JavaScript enabled) there is a handy button to check the availability of your chosen login name:

If you type in a login name that is already taken or does not comply with requirements then a message appears once you have clicked the button:

This functionality is replicated when JavaScript is disabled. The login name availability is validated with the rest of the fields when the form is submitted:

It is important that JavaScript is developed in an accessible manner. Unfortunately, many known HTML accessibility problems can also result from the inaccessible use of JavaScript. For instance, the following is a list of accessibility issues applicable to both HTML and JavaScript.
Specifically, there are a number of common JavaScript accessibility errors.
One of the most common misuses of JavaScript is to create inaccessible flyout menus. When JavaScript is used to create flyout menus, the relevant head navigation item must be a link which should link to a page that contains the links to the sub-navigation present in the initial flyout menu.
In the following example a flyout menu appears when a user hovers their mouse over a particular menu. With JavaScript disabled the flyout menu does not appear, however the initial navigation item (eg. “Business”) does not operate as a link and is therefore inaccessible.
Site with JavaScript enabled (mouse hovering over ‘Business’ navigation item)
Site with JavaScript disabled (mouse hovering over ‘Business’ navigation item)

In the following example a flyout menu appears when a user hovers their mouse over a particular menu.
Flyout menu

With JavaScript disabled the flyout menu does not appear, however the initial navigation item (eg. “About us”) operates as a link. This link goes to a page which includes a list of the links that were available via the flyout menu.
“About us” page that contains flyout menu items as text links

JavaScript can also be used to create expandable and collapsible menus, such as in the following example:

With JavaScript disabled the default presentation for expandable/collapsible menus should be to display all menu items and sub-items such as in the following example:
Enter your email address to subscribe or unsubscribe from the eGov What's New mailing list.
Please enter email address of the person you wish to send this page to.