[Javascript] proper use of 'void' and WCAG/Section 508 ?

Stone, Timothy tstone at cityofhbg.com
Fri May 2 10:09:16 CDT 2003


Greetings...

I'm cleaning up a number of pages to better meet WCAG/508/Bobby. The gist of my question is how to state onkeypress when I don't use it, but need it to meet Bobby AAA standards. So let me explain...

Specifically, I use an script called "OpenImage" (edited to meet HTML 4.01 Trans and WCAG/508). OpenImage generates a dynamic document and opens a window. This method eliminates the need to create "container pages." Further, to make the links that call OpenImage Section 508/WCAG, I provide fault tolerance when JavaScript is disabled.

example of a link:

<a href="/path/to/image.(gif|jpg|png)" title="My Foo" target="imgWindow" onclick="openimage(args...);return false;"><img src="/path/to/thumbnail" alt="My Foo" width="10" height="10"></a>

Note:
The target is defined in the OpenImage script.
The event "onclick" specifically returns false to make the link fault tolerant as noted above. More information on this accessibility guideline is found here [http://www.cs.tut.fi/~jkorpela/forms/javascript.html#window]

Now, WCAG specifies that event handlers should not require the use of a mouse.

onclick is invoked by a mousedown event, and while not appearing to be documented, by pressing enter on the keyboard when focused on an A element. My dilemma is the WCAG guideline...

onclick must be accompanied by a onkeypress event handler "if you must use 'device-dependent attributes, provide redundant input mechanisms (i.e. specify two handlers for the same element, both of which have the same code associated with them'

Well, aside from the bile welling up inside me at the thought of repeating code, I conceded and edited the link as follows:

<a href="/path/to/image.(gif|jpg|png)" title="My Foo" target="imgWindow" onkeypress="" onclick="openimage(args...);return false;"><img src="/path/to/thumbnail" alt="My Foo" width="10" height="10"></a>

Syntactically, is this a correct use the onkeypress event handler?

... onkeypress="" ...
... onkeypress="void" ...
... onkeypress="return false;" ...

or other? Can I call onclick in onkeypress (onkeypress="onclick")? I've never seen it done nor documented.

Essentially I don't need the onkeypress handler, but I'm also trying to meet Bobby AAA (bobby.watchfire.com) requirements. By the literal interpretation I believe I could state that I'm meeting WCAG 1.0 but Bobby is a recognized "label" for accessibility.

Thank in advance!
Tim

--
/**
 * Timothy Stone      . Sun Certified Java Programmer
 * Web Master         . tstone at cityofhbg dot com
 * City of Harrisburg . 717.255.7297
 * Pennsylvania USA   . 717.903.9162
 *
 * "Censorship always defeats its own purpose,
 *  for it creates in the end the kind of society 
 *  that is incapable of exercising real discretion."
 *  --Henry Steele Commager, Historian
 */


More information about the Javascript mailing list