Interfering with opening in new tabs


I make regular use of command/control while clicking links to open target pages in new browser tabs. You probably do too! It’s especially useful when browsing search result pages, so you’re not constantly flicking between each result and the original search. This is established, expected behaviour… so naturally, JavaScript to the rescue!

There are certain sites that prevent you opening a new tab when clicking a link, either due to a deliberate design decision, or as a side-effect of poorly-written code. Both of these are bad design for accessibility, and for me wanting to shop on your site.

Here’s an example where I saw a site using an event handler to redirect people to the correct product page:

<a href="$PRODUCT" class="js-gtm-push-event-with-callback"

Despite having the target page in the href attribute as a link is supposed to, the JavaScript kicks in upon clicking it. This prevents the new tab request.

I’m leaning towards using NoScript full time again. It breaks so many sites, but counter-intuitively it breaks others into working again. Isn’t that the modern web in a nutshell?

Author bio and support


Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person in bios. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.