What I really want browsers to adopt is an SPA breaking policy, where click handlers for <a> elements are ignored for non-whitelisted sites.
What I really want browsers to adopt is an SPA breaking policy, where click handlers for <a> elements are ignored for non-whitelisted sites.
None of our SPAs use <a> elements for clickable navigation. In fact, most of them attach a click listener to the root element, then let the individual clicks bubble up to there. We use data parameters on the individual elements, and if the click handler sees one of those, then it activates the history state/navigation.
In terms of autoplay, a trick we have to play for iOS is, when you click on something we play a 0.25 second silent MP3 through the audio element. Once that's done, it's "active" and we can use it to play audio.
It's a radio "boombox" type application, so this feature is expected by our users to keep audio playing when they navigate to different features within the player.
This breaks a lot of navigation features though, right? For example, middle click or control click to open in a new tab, hovering to see where the link will take you, right clicking to save, copy, or share a link, etc.
Why not just have them be anchor elements with hrefs that refer to the URL that you'll be using the history state with? You can still listen to the click events and perform the required history updates and navigation when that occurs, but if the user interacts with that link outside of just clicking it, it'll behave as they expect. Depending on how your navigation works, this could well be less work overall - this has certainly been my experience with similar projects.
Either way, my proposal would make sites that eliminated or hid <a> elements stop working by default, which would disincentivize hostile UX practices.
For sites where SPA behavior is necessary (like Spotify), opting in could be done with a one-time browser prompt, like how location access and DRM playback are handled.
This seems like a more realistic solution than just avoiding these sites altogether, for the same reason that people use ad blockers instead of just shunning sites with ads.
It's completely unrealistic to break a major browser API.