←back to thread

Just use a button

(gomakethings.com)
285 points moebrowne | 1 comments | | HN request time: 0.361s | source
Show context
lyricaljoke ◴[] No.45775130[source]
My very similar pet peeve is about websites that use `onclick` handlers and similar to implement navigation. Just use a damn anchor tag, which gets you correct link behavior for free:

* works with middle click for new tab

* integrates with accessibility devices

* works with right click + open in new window or similar options

* etc. etc. etc.

If it's notionally navigation, don't use javascript soup: use a link.

replies(11): >>45775742 #>>45775887 #>>45776191 #>>45776485 #>>45776938 #>>45776972 #>>45777023 #>>45777190 #>>45777640 #>>45779426 #>>45779654 #
derefr ◴[] No.45776938[source]
I wonder why browsers don't intercept JS-triggered navigation (or history.push) events that happen with a click handler on the stack — where it can be determined from the event data of that click handler that the user additionally used the middle mouse button or was holding cmd/ctrl at the time — and rewrite them into navigation-in-new-tab. (Ideally, without making the caller aware that anything different happened than what it was expecting.)

It might not be what the developer of the site/app intended; but it's exactly the semantics the user is expressing their desire to trigger. So why not do what the user wants? Browsers are user agents, not developer agents, after all.

(Before you say "that sounds like a layering violation" — well, yes it is, but that particular layering violation already exists to support most browsers' JS engines' "suppress popup-window / new-tab navigation if the stack of the navigating call doesn't contain a click event" logic. The code ugliness was already bought and paid for; we may as well reap as much benefit from it as we can!)

replies(1): >>45776968 #
yakshaving_jgt ◴[] No.45776968[source]
> it's exactly the semantics the user is expressing their desire to trigger.

That’s not necessarily true. You could imagine writing perhaps a video game or something where this control is intended to have a different meaning. For this reason, I don’t think this is a liberty that browser developers can take.

replies(2): >>45777115 #>>45779613 #
1. 8n4vidtmkvmk ◴[] No.45779613[source]
Vivaldi recently took liberty to "restore" a scrollbar to the body tag of my app even though I had intentionally moved it to an inner div. It royally effed up my app with no workaround.

Their intentions were good, but.. you don't know what devs are going to do. As long as they're following spec, let them. Users can vote with their wallet or eyeballs.

NB: I don't want to throw too much shade at Vivaldi. I reported it. They fixed it. Still my fav browser