36

Sometimes while browsing, I'll ctrl-click a link to open it in a new tab. However, instead of opening in a new tab, it gets clicked and browsed to in the current tab as if I had clicked it normally without holding ctrl. I'm positive I'm holding ctrl down fully and that there is no faultiness with keyboard or mouse.

Occasionally, a new tab will be opened with the link but the current tab will also browse to the link concurrently.

9
  • 4
    Perhaps they are not actual links, in the sense that maybe the "link" is using an onclick operation which could mess with the ctrl+click. Can you give a specific example? meta.stackoverflow.com/questions/276138/…
    – imtheman
    Dec 20, 2014 at 0:30
  • 1
    @imtheman Great point, however, it doesn't appear to be the case, at least in the examples I've seen. I know this because I always hover my mouse over the link beforehand to verify that it's showing a URL in the status bar. An example is here: nationaljournal.com/white-house/… In the lefthand column/bar, the links to other stories appear to be their own URLS, verified by even jumping to their location in the source, however, ctrl-clicking doesn't work, instead acting as if ctrl isn't being held. Dec 29, 2014 at 17:52
  • 1
    If you look at the source code for that site you'll see this for one of the links: <a class="primary" href="/congress" onclick="var x=&quot;.tl(&quot;;s_objectID=&quot;http://www.nationaljournal.com/congress_1&quot;;return this.s_oc?this.s_oc(e):true">Congress</a>
    – imtheman
    Dec 29, 2014 at 17:55
  • 2
    While it does have an href attribute, it is overwritten by the onclick event.
    – imtheman
    Dec 29, 2014 at 17:56
  • 2
    I wrote a Firefox addon to fix this issue. github.com/danielnixon/link-fixer Mar 7, 2018 at 8:17

3 Answers 3

16

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.

1
  • 1
    This isn't fully correct. While some code designs do allow an alternate trigger that forces the page to open in a new tab, other code designs prevent this. This is more common in sites with dynamic content which doesn't have typical "pages" and instead generates the pages as buttons are clicked. In this case, there are not true "links" in the page, but rather buttons that trigger behavior more like an application. Mar 15, 2018 at 21:33
19

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.

3
  • 1
    Hi Daniel, while it's great you wrote something to address this, can you read how to recommend software in an answer, particularly the parts in bold and update your answer please? Thanks :)
    – bertieb
    Mar 7, 2018 at 8:43
  • This doesn't work on JavaScript buttons that masquerade as clickable links. Any suggestions? Jul 22, 2020 at 2:44
  • PR is welcome ;-) Jul 22, 2020 at 5:01
4

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.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .