Example for Checkpoint
9.3, continued.

Slide 72 of 120
Previous slide. Next slide.

Example 2: Use more than one device-dependent event handler to "cover all the bases": ONCLICK requires a mouse event, while ONKEYPRESS requires a keyboard event. Both are device dependent, but including both should allow anyone to benefit from the technique.

Another "script-activated button": click on it, or tab to it and press any key to activate the script. A small alert box should pop up containing a message about the prize. Pressing the Escape key will make it go away.

Here is the code that creates the button:

You will win a small prize if you
Win a different prize!</BUTTON>.

And here is the code for the script function:

<SCRIPT language="JavaScript" type="text/javascript">
function pop2() { alert ("Second Prize!") }

Finally, do not write event handlers that rely on mouse coordinates since this prevents device-independent input.

Up one level To Checkpoints for Guideline 9.
Next slide: Example for Checkpoint 9.4

Introduction: Overview Guidelines: Overview Checkpoints: Overview Examples: Overview

Previous page. Next page.

Chuck Letourneau & Geoff Freed

W3C Web Accessibility Initiative

Copyright © 2000 W3C