KuraFire Network


Latest addition: Jan 19, 2007: Times are changing

Log

AJAX and Accessibility

· By Faruk Ateş on Aug 1, 2005 · 8 comments ·

Subject level: Advanced

With DOM Scripting and Remote Scripting making their way into standards-compliant web development, people are beginning to wonder what the effect of these techniques is in screenreaders and other assistive technologies. Kevin Leitch asked me and some others about AJAX and Accessibility. Since I couldn't quite remember seeing a post discussing this in a practical matter, I figured I might as well just write out my ideas myself. Important note: the following post is purely theoretical, and is not tested yet.

The example that Kevin asked about concerned reloading a list of content on the site without refreshing the page. A simple job for Remote Scripting indeed, but what about the accessibility aspects?

We already know that screenreaders have great difficulty with content generated on a page via DOM Scripting, something that causes us headaches but which can be used to our advantage after all. Let's explore that, shall we:

  • screenreaders tend to not read generated content (it's been reported that they are very erratic in this, however);
  • we want to cater to screenreader users as well, but the most popular one, JAWS, hooks in on browsers that generally have Javascript still enabled and that can use the xmlHttpRequest object, needed for Remote Scripting

What do we want to achieve? We want our list of content to be updated, and we want it to work under all these circumstances:

  1. the user has Javascript disabled
  2. the user has Javascript enabled, but lacks basic JS-functionality, needed for our task
  3. the user has Javascript enabled, but no support for xmlHttpRequest, thus no AJAX
  4. the user has a screenreader; Javascript can both be enabled and disabled in this case, both situations must work
  5. the user is an ordinary, seeing user with a modern browser with full capabilities and Javascript enabled

So how do you cater to so many situations? Well, my theory consists of using the screenreaders' deficiencies to protect them from themselves. It goes a little something like this:

First, create the list of content:

<ul>
        <li>Foo</li>
        <li>Bar</li>
</ul>

What an amazing example. Moving on, we want users to refresh this list via a click event: a link that says something like "refresh list" and here it is:

<p><a href="">refresh list</a></p>

This covers the first goal already (an empty href attribute points to the current page, whatever page that may be), but the trick is to make this unobtrusive and work well with screenreaders.

Adding id attributes to both the list and the paragraph with the refresh-link, we can now play around with this through DOM scripting:

<p id="list-refresh"><a href="">refresh list</a></p>
<ul id="list-content">
        <li>Foo</li>
        <li>Bar</li>
</ul>

When Using Javascript for good, not evil, we cover situations 2 and 3 (Javascript enabled, necessary functionality lacking). Now comes the tricky one: screenreaders.

The concept is simple, but as indicated at the start, this post is theoretical so far, there is no test case yet. Here goes, anyway:

First, use unobtrusive Javascript to hide the existing refresh-link from visible eyes. Second, put a new link right in its place that has a text like "instant refresh" as the label, then add an onclick event with Javascript that does unobtrusive checks for functionality and, if all is well, goes ahead with AJAX-flavoured goodness (odd image for Dutchies) to add new content to the list and returning false on the link (preventing a refresh).

The crux of it is, screenreaders should not read out the generated link, which a blind user then cannot "click" on, meaning their link will be a normal page-refresh link. Only those who can see the generated link will get a link that invoke AJAX-magic.

A test case will be made for this, but I'm currently wondering how useful it will be. Of course, if initial testing proves that this method is flawed, that's one thing, but the truly reliable way of testing this is to use many different screenreaders on many different configurations, and then that's only the beginning. Real accessibility goes a long ways beyond that, still, but I do believe that the above situation would give the most accessible result with the least amount of hassle.

So the catch is to just generate a link for seeing users, add all necessary scripting to the generated link and having the original link behave in unobtrusive manners, the way it would with Javascript disabled. Now, if this approach does indeed work, it would apply to other things as well. Think form buttons for instant previewing and submitting of comments through AJAX magic. There's a lot of potential here, I believe, and I'm definitely going to look into it more as I find time for it.

Bookmark: Newsvine del.icio.us Digg

Comments

8 comments

#1 · Mark Wubben · Aug 2, 2005 (09:23)

What a hassle :) It's really too bad we can't figure out if the user's using a screen reader, would save us a lot of trouble.

Also, point two and three in your list of circumstances are basically the same, no?

#2 · Faruk Ateş · Aug 2, 2005 (10:33)

Mark: indeed, it's still a hassle, but not that much, really. Most of it is simply unobtrusive practice.

And yeah, point 3 is just a copy of point 2 with a minor change, in the Javascript code needed for that. Still, it's an important step :-)

#3 · Chris · Aug 2, 2005 (14:46)

What's with the screenreader fetish? Accessibility does not only mean that every possible UA on this planet is supported. It also means that a sighted user who cannot use a mouse will be able to use your applications. Generated content will be read out by screen readers and when you make the links clickable instead of only dragable or hoverable they can be used by blind users, too. However, when it comes to AJAX and accessibility it is IMHO more important to think about users with dexterity issues than blind ones.

The whole debate about what screen reader supports what sounds like a new issue of the browser wars to me. Just because it is an expensive tool and I am not familiar with it makes it something I really should bow before.

#4 · Faruk Ateş · Aug 2, 2005 (16:00)

Chris,

It's not a fetish, it's just something that was asked. Why not focus on others? Because generated content only is a real issue with screenreaders, not with assistive technologies such as alternative keyboards or mice, nor for the visually impaired. The issue with AJAX and Accessibility is how it's handled by everything that isn't visual, in this case that's only screenreaders.

Why "everything that isn't visual" ? Because that's the only relevant difference between AJAX and non-AJAX.

#5 · Kev · Aug 3, 2005 (11:36)

Many many thanks Faruk, this has definitely helped my thinking on the process.

#6 · Ed · Dec 28, 2005 (20:01)

Keeping things unobtrusive offers a good fallback mechanism to user agents not supporting AJAX but yet again it does beg the question "why bother with AJAX?"

Although there is talk about AJAX and accessibility, even AJAX and SEO, there's a big need for a "best practice" write up on form controls, navigation systems and content rendering. The less of an overhead accessible AJAX becomes the better.

#7 · Victor · Mar 15, 2006 (01:14)

The problem of not being able to detect a screen reader is linked to the fact that DOM, as it seems, runs in browser's process space. Screen readers do set a systemwide hook but this can be detected only by software apps and activex ctrls such as Flash.
There is an ongoing effort by IBM, Mozilla and screen reader manufacturers to get DHTML support going, check
www.mozilla.org/access/dhtml.

#8 · Philip · Mar 15, 2006 (09:38)

I've implemented and tested this a few times.

All times are in CET. It is now 19:44.