Hi, as far as I'm aware the best practice for setting onclick events with anchors is something like <a href="javascript:;" onclick="..."> ... but this produces an ugly "javascript:;" message in the status bar on most browsers.... so surely there's gotta be a better way? is there no better way for accessibility?
that defeats the status bar effect, but i heard it's not good for accessibility due to it sending non-javascript users to "#" which is normally top of page. did i mis-hear?
You could also try: <style> .spanLink { cursor: pointer; } </style> <span class="spanLink" onclick="doSomething();">Link Text</span>
If we're talking accessibility, how do you activate that with the keyboard? It probably would have to be something like: <span tabindex=1 class="spanLink" onkeypress="doSomething();" onclick="doSomething();">Link Text</span> Code (markup): The best way to cater for non-JS users is either to provide an alternate URL. <a href='alternateURL.htm' onclick="doSomething();return false">Link</a> Code (markup): or less preferably to have script-generated links. Here's another idea that I won't actually code. All links with onclick handlers are given href and title attributes thus: <a href="#REQUIRES_JAVASCRIPT" title="REQUIRES_JAVASCRIPT The proper title text" onclick='dosomething();return false'> Code (markup): Then on page load, loop through all links stripping 'REQUIRES_JAVASCRIPT' from the href and title.
If you want the page to be accessible, the href would be to a normal, static page anyway <a href="page.html" onclick="showpage(); return false;">Fork</a> Code (markup):