Shampoo Regardless of UI framework, we can capture the click and handle " /> Shampoo Regardless of UI framework, we can capture the click and handle " /> Shampoo Regardless of UI framework, we can capture the click and handle "/>

Can I respect a user's "Open links in new tab" setting in an SPA?

72 Views Asked by At

Say we have a single-page application with a link:

<a href="/products/12">Shampoo</a>

Regardless of UI framework, we can capture the click and handle the navigation without a reload, rearranging the UI and using the history API. By using <a href..> as the basis, regular links behaviours such as being able to copy the URL or open the link in a new tab are preserved.

However, the user browser preference "open all links in a new tab" is not respected because we capture the click before the browser gets to it. Question: is there a way to respect such settings without a page reload?

I thought there might be a way to capture and handle (same-origin) navigation just before it happens but there don't seem to be any APIs for that.

0

There are 0 best solutions below