W3C home > Mailing lists > Public > w3c-wai-gl@w3.org > July to September 2005

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

From: Gian Sampson-Wild <giansw@ifocus.com.au>
Date: Tue, 23 Aug 2005 12:52:32 +1000
Message-ID: <BB5079183D9A3844A4D8C51168F3872D3C17D8@SAPPORO.ifocus.com.au>
To: "Isofarro" <lists@isofarro.uklinux.net>, <Becky_Gibson@notesdev.ibm.com>
Cc: <w3c-wai-gl@w3.org>

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.
-----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
> added.  Just a thought...
> </andrew>
> Good idea since href is not a required attribute. But,  as you
> 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
* 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.

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:59:38 UTC