WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Aural readers and onClick JavaScript

for

From: James Denholm-Price
Date: Aug 3, 2006 5:50AM


Hi Sam & all @ WebAIM

On 20/07/06, Sam < <EMAIL REMOVED> > wrote:
> We're beginning to use JavaScript to render a "Table of Contents". Right
> now, there are no anchor tags in the table. Instead, each row <tr> is
> dynamically given an onClick event. In other words, it's not visible in the
> HTML at all.

Just my opinion: Using onclick on a <tr> with a title is a bad idea on
several counts:

1. onclick is software-dependent & device-specific.

2. <tr> do not have "click" behaviour (affordance) so no-one's
expecting a click to have an effect (if you do CSS cursor:pointer;
it's still visual; aural CSS is unsupported.)

3. the title may not be read automatically (who's expecting <tr> titles??)

If the bulk of the TOC is static HTML then it should be easy enough to
add an <a> element inside the cell which (1) can accept onfocus, (2)
has "click" affordance and (3) is more likely to be associated with an
action and/or a title attribute.

> I'm guessing, but want to verify, that aural readers won't see the onClick
> event at all, so in spite of the "title" in each <tr> tag instructing users
> to click to visit the module, the aural reader won't get it. Am I right?

>From your description it seems the event handler will trigger a page
change. The reader ought to spot that (it's dynamic changes within the
existing page that are difficult [1].)

> We will need to redesign the "Table of Contents" to explicityly show the
> links as anchor tags in the HTML?

I think that would be the best idea. After all, what about your users
who have disabled or can't use JavaScript? They'll see the title but
onclick will fail (go "unobtrusive"! [2])

HTH,
James

[1] http://domscripting.com/blog/display/64
[2] http://www.onlinetools.org/articles/unobtrusivejavascript/