#StackBounty: #javascript #react-router How to handle "intention to open link in new page" in a SPA application?

Bounty: 50

Well in my (react) single page application I have a lot of “internal links”. These links work by changing the url using a router store. (Mobx+react).

As html standards warn against using href without an actual href, and if one uses on_click event a button -styled to look like a link- should be used.

This works perfectly fine. Except now that I wish to improve use, I wish to allow consumers to press ctrl+click, middle mouse or whatever the keybind is of the esoteric browser the user uses, to “open link in a new tab”.

Is there a way to get the “intention” of a click by the browser? – Ie to see if the user’s intention was to open the link (button) in a new tab?

Without letting the user reload the page if clicked on the link normally?

Or from the other side: how can I prevent a full page reload when clicking on a link that is a relative url and opens in the same window?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.