WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Is javascript a big issue?

for

From: Tim Beadle
Date: Mar 15, 2004 2:55AM


On Mon, Mar 15, 2004 at 09:38:48AM +0000, Chris Price wrote:
> I wasn't specifically thinking about javascript (dynamic) menus. Rather, I
> was thinking of where a link is coded <a
> href="javascript:clickLink('whatever')"> and no allowance is made for
> javascript not running so the link looks OK but when you click, nothing
> happens.

If using JavaScript in links is avoidable, then avoid it.

If not, then do something like this:

<a
href="alternative-for-non-js.html"
onclick="clickLink('whatever'); return false;"
onkeypress="clickLink('whatever'); return false;">Blah</a>

If you're just relocating to a url using JavaScript, you can use this.href as
the value you pass to your function, if you're (for instance) launching a page
in a pop-up window. Not that you'd ever do such a thing, of course ;)

E.g.

<a
href="page.html"
onclick="popup(this.href); return false;"
onkeypress="popup(this.href); return false;">

HTH,

Tim
--
"If you not hope to receive the similar letter again , please click here
remove. Thank you" -- Unknown 419 spammer


----
To subscribe, unsubscribe, suspend, or view list archives,
visit http://www.webaim.org/discussion/