As other answers have mentioned, avoid the use of javascript:
href links, and it is entirely unnecessary in event handler attributes. However, since A
tags are sometimes still semantically correct, you will need to put something in the href
attribute if you want your :link
and :hover
CSS styles to be applied to the element in Internet Explorer. In this case, use:
<a href="#" onclick="doSomething(); return false;">Link</a>
Or
<a href="javascript://" onclick="doSomething();">Link</a>
There is one (somewhat obscure) bug with the javascript protocol - in Internet Explorer*, it will think you are leaving the page when you click the link. If you are using window.onbeforeunload, then your navigate-away message will appear at this time. For this reason alone, we've stopped using the javascript protocol completely so we don't have this bug show up because we forgot to check for it when we add a navigate-away message to some page.
* I probably should have specified the version when I first wrote this. I don't remember at all, but just in case the bug is present only in a now-mostly-defunct browser like IE 6 or 7, you are probably best to test it yourself.