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

liorean liorean at f2o.org
Fri May 2 10:40:04 CDT 2003


Stone, Timothy wrote:
> 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...
> 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'
> 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.

onkeypress="whatever" where whatever is a legal JavaScript. If you use
"return false;" you cancel the event, if you do nothing or return true,
it fires. You can also use "return this.onclick();" if you wish to
connect it to the onclick handler.

One thing else: the click event isn't a purely mouse event in any
browser - it's the event of activating the default action of the
element. That means onclick on a button is equal to the fictious
onpress, and onclick on a link is equal to either the fictios
onmouseclick or the onkeypress if the key pressed happend to be enter
(and in some browsers also space). They would also be equal to the
fictious onactivate if the user has a CLI or VCI (Voice Control) and
wants to "open" the link or "press" the button.

Besides, the onkeypress event isn't a [DOM3 Events] key event - only
keyup and keydown are.

-- 
liorean <mailto:liorean at user.bip.net>

ViewStyles, ViewScripts, ToggleStyles and GraphicsInfo bookmarklets and
Theme Switcher, Cookies Handler scripts:
<http://liorean.web-graphics.com/>




More information about the Javascript mailing list