33

When I perform a search, I often want to open several results in new tabs using Ctrl+Click. Until recently, I don't remember having any problem doing this.

Today, I cannot open search results in new tabs using modifier keys. For example, when Ctrl+Click-ing on any link in https://stackoverflow.com/search?q=foobar, the operation is treated as a normal click. I can still use "Open in new tab" in the context menu, but that's quite a bit slower.

I can reproduce this behavior in Firefox and Chrome for Windows.

This behavior does not appear on a few other SE sites I tested.

13
  • 1
    Works fine for me in FF for Windows.
    – nobody
    Nov 5, 2014 at 18:38
  • Confirmed in both Chrome and Safari on Mac.
    – Martijn Pieters Mod
    Nov 5, 2014 at 18:42
  • 8
    Related: Question links now have annoying suffix. It is the changes the team made for that issue that are the cause here, I'm sure.
    – Martijn Pieters Mod
    Nov 5, 2014 at 18:46
  • Same is happening here in FF33.
    – Compass
    Nov 5, 2014 at 18:49
  • 1
    Chrome 38 on Ubuntu - confirmed.
    – Scimonster
    Nov 5, 2014 at 19:44
  • Ctrl+Click works fine for me from search with IE 11, but Shift+Click doesn't.
    – Kendra
    Nov 5, 2014 at 19:47
  • Control+Click works fine under IE10, but Shift+Click doesn't. Both work fine on other links.
    – Pokechu22
    Nov 5, 2014 at 19:50
  • safari mac repro
    – nicael
    Nov 5, 2014 at 19:52
  • 6
    Hmmm... I've always used middle-click for that. Reproduced in Chrome 40.0.2211.0 on Windows 7.
    – canon
    Nov 5, 2014 at 20:05
  • Can repro FF 33.0.2 on windows. Middle click works (opens in new tab), ctrl-click does not open in new tab. Nov 5, 2014 at 20:17
  • Confirmed both on Firefox 31 on Ubuntu - Neither shift-click nor ctrl-click work, but middle-click does
    – Izkata
    Nov 6, 2014 at 14:07
  • Is this fixed now? I can't repro on Chrome 38, Ubuntu 12.04 LTS.
    – Ajedi32
    Nov 6, 2014 at 14:22
  • @Ajedi32 Yes, it appears to have been fixed within the last hour.
    – apsillers
    Nov 6, 2014 at 14:23

3 Answers 3

5

Thanks for bringing this up. I indeed broke this with my crummy JS, and it has now been fixed. The fix is already live so you should not have any further issues. Sorry for the inconvenience.

And for anyone curious, this.href = will preserve middle clicks, while window.location.href = will not. Now I know. :)

2
  • Can you elaborate on that a bit? What is this? Is it the window object or document object? Neither seems to work for me.
    – mpen
    Mar 4, 2015 at 23:46
  • 1
    @Mark this is the anchor <a> tag.
    – Haney StaffMod
    Mar 5, 2015 at 2:15
13

The problem seems to be here:

    $(".js-search-results").on("click", "div.result-link a", function (ev) {
        ev.preventDefault();
        window.location.href = $(this).data("searchsession");
        return false;
    });

this finds the clicks on search results, prevents the default handler, and changes the current webpage.

3
  • Indeed, if I remove the result-link class of parent <div>, things work normally. This would certainly seem to be the problem code.
    – apsillers
    Nov 5, 2014 at 20:30
  • 6
    Sounds like this event handler should be a simple this.href = $(this).data("searchsession"); return true;
    – Bergi
    Nov 6, 2014 at 0:12
  • @Bergi Don't know about the assignment, but the whole callback looks odd to me. Returning false in jQuery automatically calls ev.preventDefault(), so that's not needed. But it sounds like that's the cause of the bug, so don't even bother with returning true - jQuery treats that the same as if there was no returned value...
    – Izkata
    Nov 6, 2014 at 14:13
3

I can reproduce this with Google Chrome. However I always use Middle-click for this task, which appears to be unaffected.

3
  • 1
    My laptop doesn't have a middle click button.
    – Scimonster
    Nov 6, 2014 at 13:46
  • @Scimonster Clicking left and right at the same time is usually configured to act as a middle click
    – Izkata
    Nov 6, 2014 at 14:15
  • @Izkata Awesome! Who know?! (You, apparently. ;))
    – Scimonster
    Nov 6, 2014 at 14:15

You must log in to answer this question.

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