News for hackers. Stuff that matters.
Re:Ask HN: the current state of the empty # in 'a href' by plasma on Monday March 28, 2011 @06:28AM (#2377838)
If you want to retain IE6 compatibility (usually a must for government related sites!), I've found this technique is pretty solid for cross browser platform compatibility (IE6-9, FF, Chrome, Safari):

<a href="#" onclick="DoSomething(); return false;">My link</a>

1) When you hover over the link, a 'hand' cursor appears for every browser (due to the #)

2) IE6 (in particular) won't barf at running your javascript code found in the onclick handler.

If your href tag contained "javascript:void(0)" instead of "#"; your code may not be run under IE6.

3) Because you 'return false' on the onclick, all browsers still avoid leaving the customers web browser with an unnecessary # in the top of the Url bar (as the click is effectively cancelled).

There are no comments on this comment yet.