Why does CTRL-click not open some links in a new tab?

I wrote a Firefox add-on (boringly) named link-fixer to fix this. You can install from addons.mozilla.org. It requires Firefox 48.0 or later.

Quoting myself:

The default behaviour of ctrl+click, shift+click and cmd+click when clicking on links is to open the link in a new tab or new window. This behaviour is sometimes broken by careless developers. This add-on restores the default behaviour, ensuring the modifer keys are always respected.

Once installed there's nothing else you need to do. You can ctrl+click on any link and it will open in a new tab. It'll also solve the variation of the problem you describe in your second paragraph.


JavaScript behind the scenes

This happens when developers of such web pages intercept mouse clicks with JavaScript and do asynchronous network requests inside the interceptor, potentially to track your clicks. When the async network call returns, the JS does a programmatic redirect using something like: window.location.href = url;

This programmatic redirect will always load the page in the same tab, even if you hold Ctrl (Cmd on Mac).

Use MiddleMouse to override

Clicking middle button on your mouse or selecting 'open in a new tab' from the context menu will bypass the intercepting JavaScript code entirely and will open a link as if there were no JavaScript code at all.


Lets take this link as an example:

<a href="test.php" onclick="someFunction(this); return false;">Test</a>

The href attribute, in this case, is creating a pseudo link for readability (it will also allow the link to work even if JavaScript is disabled). The reason for this is because the onclick attribute always runs first. Big sites like Google do this to track clicks and to try to prevent a user from visiting malware sites. Because of this, for some reason Ctrl + Click does not work. However, if you use the middle-button on your mouse, that almost always works.