views:

42

answers:

1

I am working on a large website (1600+ pages) that needs upgrading to pass standards compliance. As a result, for every OnClick there has to be, say the Standards, an OnKeyPress handler, so that people not using a mouse can still access the content.

Some tags have an onclick javascript handler. EG:

<a onclick="doSumat();">

Is the following cross browser, working javascript:

<a onclick="doSumat();" onkeypress="this.onclick();" >

Will it work reliably in all browsers and will the result be the same as a mouse click for someone using a screen reader?

Edited to show a tags instead of span tags...

Edited to describe problem more clearly..

+2  A: 

In this case, why not call doSumat(); with both the onclick and onkeypress handlers?

If you need a this context, then you'll need to use doSumat.call(this);, but you can still place that in both handlers.

<a onclick="doSumat();" onkeypress="doSumat();">

With 1600 pages, I imagine you're trying to find something simple to append to every element with an onclick handler, but shouldn't be that much more complex to define rules to blindly copy everything from an onclick statement to an onkeypress expression.

palswim