I use A without href only when I'm making an actual anchor A name. When I use href=#, I always have javascript onclick return false. This won't stop crawlers but it keeps the user's history and address bar clean.
what about href='' and in the jquery onclick function, return false at the end?
Ask HN: the current state of the empty # in 'a href'
11–15 of 15 posts
Re: Ask HN: the current state of the empty # in 'a href'
#12Re: Ask HN: the current state of the empty # in 'a href'
#13I use A without href only when I'm making an actual anchor A name. When I use href=#, I always have javascript onclick return false. This won't stop crawlers but it keeps the user's history and address bar clean.
Re: Ask HN: the current state of the empty # in 'a href'
#14I've always been a fan of oi! It'll look like a link (unlike leaving the href empty), and wont ever perform wacky page scrolling tricks or mess up your URL bar. That's been my signature since 1997. Don't see any reason to change it...
Re: Ask HN: the current state of the empty # in 'a href'
#151) 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).