Say my website is example.com. On it, I have the following link: <a href="?foo=bar">Click here</a>, which upon clicking should take the user to example.com/?foo=bar.
What I want is, by default, the link should use window.history when clicked. In particular, it will use
window.history.pushState({"foo": "bar"}, "", "?foo=bar")
However, if the user e.g. "middle clicks" or right clicks and says "Open in New Tab", then the anchor link should act as normal and just open in a new tab (without erroneously triggering the pushState in the current tab). This should also preferably work with non-standard methods of opening a link in a new tab, such as using the Vimium web extension.
Is there some standard way of accomplishing this?