WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Submitting forms via javascript: Button vs. link vs. other?

for

From: Jared Smith
Date: Dec 3, 2009 4:21PM


On Thu, Dec 3, 2009 at 3:54 PM, D A < <EMAIL REMOVED> > wrote:
> Assuming Javascript is enabled (I know that, itself, can be an
> accessibility issue) what are the pros/cons of using various elements
> to act as the trigger for submission?

I think you've covered most of the issues. Naturally buttons are
capable of submitting without javascript, so that's an important point
to consider.

> Perhaps this is in appropriate and potentially an issue with indexing
> spiders and the like.

Yes, you'll have spiders following your link all the time (unless you
add nofollow... maybe), but they don't typically have javascript
enabled, so it won't really submit your form anyway.

> span (or other neutral element): pro - easy to style and doesn't have
> the cons of the above; con - is there one?

Spans cannot receive keyboard focus by default, so they are not
suitable unless you assign them tabindex="0" to make them tabable.

My approach, assuming I can't style the button how I want to, would be
to use a button in the standard HTML, then use scripting to replace
the button with my styled link, but assign it an ARIA role of button
so that screen readers treat it and identify the link as a button.
They won't know the difference between the link and a button. This
approach has all of the pros you list and none of the cons. It also
uses progressive enhancement so it works without scripting.

Jared Smith
WebAIM