Accessible IT @ NC State
Menu Home Accessible IT Services Web Accessibility Tutorials Accessibility Laws Standards Software Download Resources Search Accessible IT
For more information contact
Coordinator- University IT Accessibility 919 513 4087

Designing for Accessibility - Scripting

Design Principles

Ensure all site navigation and interoperability is device independent and can be performed using the keyboard

§ 508 1194.24 (l) When pages utilize scripting languages to display content, or to create interface elements, the information provided by the script shall be identified with functional text that can be read by assistive technology.

JavaScript is most commonly used scripting language to create HTML documents that are more dynamic, functional and interactive. When used programmatically, scripts can detect user agents, increase user interaction, control web content and other processes to enhance the functionality and accessibility of a web page.

While scripting can be used to enhance functionality of web pages, they can also make the pages inaccessible. When designing web pages using scripts ensure the JavaScript is directly accessible or provide an accessible, non-JavaScript alternative.

Accessible JavaScripts expose the content to screen readers and makes all activities device independent (performed using keyboard).

On the web, an event is a function that produces an activity like triggering a link, submitting a form, loading a page, alerting the user etc. Events can occur programmatically or as a result of user interaction.

Event handlers are scripts that trigger an activity when an event is initiated and perform both essential and non-essential functions. A function is considered

  • essential when the script performs operations that effect the web content
  • non-essential when operations are for creating special visual effects that do not impact the content or user transaction

 

Script Function

JavaScript Accessibility

Scripts essential to the functionality of a page

  • Include <noscript> tag to provide alternative content so that the page will make sense and can still be used when scripts are turned off or not supported.
  • Do not use scripts to provide blinking and moving text
  • Use server side scripting for background functionality that is essential to the web page, for example, making calculations in background.

Image roll overs - image changes when it receives focus with mouse or keyboard

  • None if used for visual effect only (non-essential)
  • If image roll-over provides information, place the information in the alt tag of the rolled images

Emulating browser functions like back, close window, print page etc

  • None as they are available within the browser

"Programmatic Animations" or timed events like timed presentations

  • Provide controls to stop, pause or restart event

Page refresh, redirects and event timeouts

  • Avoid script links within the < a> tags
  • Avoid page refresh especially within the Meta tags
  • Provide user controls for "time-out events"
  • Provide warnings that the page will refresh or event will time-out

Change focus to a different window without warning - Links to pup-up or new windows

  • Provide warning of change of focus or opening of new window
  • Provide alternative content in <noscript> tag

For events that do more than just change the presentation of an element

  • Use device-independent event triggers like "onFocus", "onBlur" and "onSelect" rather than user interaction-level triggers like "onmousedown" or "onclick".
  • If you must use device-dependent triggers, provide redundant input mechanisms; for example, specify two handlers for the same element. Use "onmousedown" with "onkeydown" or "onclick" with "onkeypress".
  • Do not write event handlers that use double-clicking ( "ondblclick" ). There is no keyboard equivalent device-independent handler.
  • Do not write event handlers that rely on mouse coordinates because this will prevent device-independent input.

Dynamic menus or fly-outs (mouse dependent)

  • Make sure each of the top level menu items is keyboard navigable
  • Make each item a link in its own right
  • Provide a link to the same menu options (as in the dynamic menu) using static text links.
  • Provide a method for users to switch to alternative menu formats
  • Do not create fly-over or drop-down menus that cover content

Menus using style sheets and form controls like drop-down combo boxes

  • Create menus that work when scripting or style sheets are turned off.
  • Do not use absolute positioning to construct menus. This prevents someone from resizing the menu to suit their needs, such as using large fonts.
  • For menus that use drop-down combo-boxes do not automatically launch the link "onchange" but provide a "Go" button. This will help ensure that the correct option is selected before launch.

Forms

  • Do not move focus automatically from one form element to another when the end of field size is reached. This makes it impossible to use SHIFT-TAB to move back through the fields to correct errors.
  • Alert user to form-timeouts and provide a mechanism to disable time-out feature
  • Do not automatically submit the form after validation.
  • Ensure the form information and cues make sense and can still be used when scripts and style sheets are turned off.
  • Ensure that placeholder text used as prompts within form fields are ready for edit when focus moves to that field.
  • Provide a static version of forms that have fields that are dynamically altered when the form is filled.
  • Do not reset all form content when information is not validated. Provide a mechanism to automatically move the user to the first invalid field and clear the field and give the associated error message.

Use Javascript to enhance a functionality that is already present. The <noscript> element can be used to to provide alternative content for when scripts are not supported or when users have the script functionality turned off.

Code with <noscript> element

<script type="text/javascript">
<!-- document.write("Hello World!") ;
document.write('<img src="myimage.gif" alt="text description" border="0">') //-->
</script>

<noscript>Your browser does not support JavaScript!
Hello world!
<img src="myimage.gif" alt="text description" border="0">
</noscript>

     

back to top