News for hackers. Stuff that matters.
Re:Why using anchors as buttons sucks by yaix on Sunday February 05, 2012 @03:55AM (#3553665)
Why don't you add href='#' and return false from the click event. Nothing gets added to the history that way.

Better yet, add a href='/uri/to/script' as a fallback in case the user has JS disabled.

Re:Why using anchors as buttons sucks by citricsquid on Sunday February 05, 2012 @04:08AM (#3553680)
I was under the impression this (href=uri, js fallback) was the accepted standard, is it not?
Re:Why using anchors as buttons sucks by trb on Sunday February 05, 2012 @04:25AM (#3553709)
It is, the comments on the blog say as much as well. Use href="#" if a link makes no sense (anything UI-related and ephemeral, basically).
Re:Why using anchors as buttons sucks by pornel on Sunday February 05, 2012 @08:06AM (#3553954)
Even many UI-related items could have sensible URL, e.g. href="#show-widget" (and read location.hash and perform that action when page is loaded).

The href is not only for JS-less browsers, it's also for links opened in new tab or saved in browsing session.

Re:Why using anchors as buttons sucks by pilif on Sunday February 05, 2012 @09:27AM (#3554089)
You really should not return false from event handlers. Returning false is equivalent to calling both preventDefault() (that's what you want) AND stopPropagation()

By stopping propagation, you break delegation and make it impossible at worst and very random at best to add another handler to the same event.

Just use preventDefault o stop the browser from following the link.

Re:Why using anchors as buttons sucks by cema on Sunday February 05, 2012 @10:51AM (#3554308)

  Returning false is equivalent to calling both preventDefault()
  (that's what you want) AND stopPropagation()
This is so in jQuery. In basic Javascript "return false" does not stop the propagation. See http://stackoverflow.com/questions/1357118/javascript-event-...