Forbid links to open new tabs in Google Chrome

18
2013-11
  • Andrzej

    I'm looking for a solution to forbid links in Google Chrome to open new tabs (in most cases it is a issue).

    So, I want all links to open pages in currently active tab, not in new tab.

    I tried a wide range of addons (for ex. "Death to target=_blank") and greasemonkey scripts that are supposed to remove target=_blank attribute but none of them worked.

    It is extremally anoying when I want to switch between accounts in GMail or navigate from GMail to GDrive. I always get the new tab opened and I need to close last tab manually.

  • Answers
  • Sly

    You can use a pure Javascript method:

    var links = document.querySelectorAll('a[target="_blank"]');
    for (var i = 0; i < links.length; i++) links[i].target = '';
    

    Or you can use jQuery:

    $('a[target="_blank"]').each(function() {
      this.target = '';
    });
    

    Then create an extension with it and install it to your browser. Chrome Developer Page


  • Related Question

    Google Chrome-like tab behavior in Opera
  • RamyenHead

    How can I have Google Chrome-like tab behavior in Opera?

    In Opera, when I open some links in background tab and then close the current tab, it just goes to the left tab.

    Update: Google Chrome tab behavior

    Google Chrome tabs work in a way that I don't have to open new window or move tabs while I just browse the web and open a lot of links in background tabs and then in each of those link, open another set of links in background and so on.

    After some testing with reddit pages, here's how I think Google Chrome tabs work:

    • Open a bunch of links (from the same page) in background tabs, where are the new tabs? The new tabs are immediately to the right (of the opener tab).
    • Close a tab, then which tab is activated/focused? A sibling tab (of the closed tab) is closed, if it exists. (Tab X is a sibling of tab Y if X and Y have the same parent tab Z. Tab Z is the parent of tab X if X is opened from Z.) If you close tabs successively, sibling tabs to the right are closed (because they the ones being focused after each closing) and then the sibling tabs to the left are closed, and then the focus is on the parent tab, which is usually immediately to the left of the last closed tab. It doesn't work this way if you move tabs around.

    Also see tabbed browsing in Google Chrome


  • Related Answers
  • 8088

    When closing a tab