Skip to content

Comment on Using pushState? Make sure your links are fineparent

Comments

I read the article as simply suggesting that developers create real, genuine <a>-tag links in their modern pushState-using web apps. Doubtful that there are enough people specifically overriding middle-clicking on links to warrant a blog post.

For example (and not to call anyone out), there's this demo (warning: will fill your history): http://bodytag.org/rollstate/

Looking at its source, it uses real <a> tags for its pushState() links, but with href="#". If you click on "contact", then middle-click "about", a new tab will open to "/rollstate/contact" (which 404s, another pushState() no-no).

Actually, there are. If you override the click handler on a link, you'll override the Cmd-click handler as a side-effect.

My site does this (by accident), and I eventually had to ask StackOverflow to find that Sammy.JS (my client-side router) was doing it.

Also, Quora does it.

(It's infuriating when I try to middle-click a run of interesting-looking questions and it "steals" the clicks.)

i assume this is much like the js-driven crap that's been around for over a decade now where the mouseover text looks real but the actual href is "javascript:void(0)" or something?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.