Skip to Page Content | Navigation for Module


Navigation for Module 10: Scripts/Java
Page 5 of 19

Scripting Events

Many individuals with visual impairments or motor disabilities find it difficult or impossible to navigate using a mouse. Therefore, many of them rely solely on the keyboard for navigation. This clashes with the way that many developers have written scripts. Traditionally, they worked only with methods such as onMouseDown, onMouseOver, or onClick. These methods are described as device-dependent because they interact with one device only - the mouse.

A newer and more general approach is to pair onMouseOver and onMouseOut with onFocus and onBlur. These two new methods are device-independent and broaden the kinds of interaction that can occur. Essentially, the developer will be specifying two handlers for the same event. This idea of pairing event-handlers can be applied further, such that keyboard events are paired with mouse events. A listing of pairs of handlers you should use together to handle events are.

Depending on the way this is implemented by the browser, be aware that some of these may be duplicates. Make sure you test your scripts on several different browsers. Also, be aware that onBlur and onFocus may not be supported in older browsers, but should still be used.

Note: Avoid using the onDblClick event. It has no keyboard equivalent. The double-click event can also present difficulties for individuals with motor skill disabilities.

Code sample for accessible rollover

<IMG src="A.jpg" onMouseOver="document.images[0].src='B.jpg'" onFocus="document.images[0].src='B.jpg'"
onMouseOut="document.images[0].src='A.jpg'" onBlur="document.images[0].src='A.jpg'" alt="Alternate Text">

Just as you can access the src attribute for images, you can access other attributes, including the alt attribute. Changing an attribute does not affect the accessibility of that object.

Most rollovers do not present any accessibility obstacles because most of them only highlight the text in some way. In this case, it is not critical for the user to see a simple graphic change. Rollovers only become inaccessible when they present new information, so doing this should be avoided. Also, remember to use onFocus and onBlur events along with the more traditional onMouseOver and onMouseOut.

The next page will discuss the document object model.

Top of Page arrow up
       Page 5


 
-- END OF PAGE