At 06:03 PM 12/6/2004 +0000, you wrote:

Veine K Vikberg wrote:
<a href="wharever.com" onkeypress="window.open(this.href); return false;" onclick="window.open(this.href); return false;">Whatever.com</a>

*Don't* use onkeypress, as Mozilla browsers - and rightly so - treat a TAB as
a keypress as well. Using onkeypress makes it impossible for users to TAB beyond
that particular link. Onclick is, despite its name, device independent, as the vast
majority of browsers (I'm actually compiling a list which I'll publish later tonight)
trigger the event via the keyboard as well (in the case of a link, hitting "enter"
will trigger the onclick)

Well, my link was given for XHTML Strict, in where my solution is the only way to both make sure it is to the greatest extent accessible as well as validating the code.


Let me explain a little more;

The above mentioned code is the HTML 4.x target="new" in a newer fashion, where the new window is launched by passing the href attribute to the window open object's method. The return false is returned from the event handler. If Java script is enabled the false returned is prohibited from being processed and the Java script event handler does it's task. Now in the event of Java script turned off, the link is a 'normal' href link, which will be carried out by the browser, and the user can visit that link, however in the same window as they were in (not opening in a new window). It's basically a catch-all scripting to be as accessible as possible. Since my prime concern with most of the web sites I build is accessibility this is the script that will work for most occations, and this code is not platform/device dependent. The reasoning is to provide onclick for mouse users and onkeypress for using a keyboard. I do this to make sure that the most users can access the pages I build (my target is supporting down to NS/IE 4.x)

*IF* there was a way of completely not using Java script I would go with that, but there is no way around the issue as I have found, since the latest statistics I saw on the Java script subject was that 20-25% has it turned off in their browser, and that Flash is now ahead in usage. That maybe be all good and well, however the usage of Flash makes the accessibility issues larger (however can be solved) but few wants to pay the difference in development cost.

   HTH, Regards
       ~Veine


Veine K Vikberg http://www.vikberg.net Professional Web Guru

Reply via email to