RE: [TECHS] Use of anchor tags to invoke JavaScript

I can think of one more:
<a href="javascript:void(doSomething());">Action Link</a> ...which
should prevent the browser from doing *anything* but run the code...
assuming it has javascript support, of course.  I'd have to think about
which method is best.
Cheers,
Gian
 
-----Original Message-----
From: w3c-wai-gl-request@w3.org [mailto:w3c-wai-gl-request@w3.org] On
Behalf Of Isofarro
Sent: Thursday, 18 August 2005 4:27 AM
To: Becky_Gibson@notesdev.ibm.com
Cc: w3c-wai-gl@w3.org
Subject: Re: [TECHS] Use of anchor tags to invoke JavaScript


Becky_Gibson@notesdev.ibm.com wrote:
> 
> <andrew wrote>
> Why not:
>  <a onclick="doSomething();return false;">Action link</a>
>  
> I don't know what different user agent would do with this.  It is 
> possible that it wouldn't be in the tab order unless a tabindex was
also 
> added.  Just a thought...
> </andrew>
> 
> Good idea since href is not a required attribute. But,  as you
suggest, 
> the anchor is not in the tab order if there is no href.   Adding the 
> tabindex="0" attribute did not solve the problem since older browsers 
> did not include it in the tab order thus there is no keyboard focus. 


Thinking about it logically, the a element serves two purposes:
* to add a hyperlink to another document or a point inside the same
document
* to be a destination for a hyperlink.

The first is accomplished using an href attribute.

The second doesn't and shouldn't by default do anything if activated. 
Its a destination, so using the name attribute gets that done. This has 
largely been superceded with the more modern id attributes on elements.

Trying to put a tabindex on an anchor with no href attribute just 
strikes me as fighting against HTML instead of working within it.



Mike

Received on Tuesday, 23 August 2005 02:52:32 UTC