Prevent window.open from focusing

The proper way would be to use extension API:

chrome.tabs.create({url: "http://...", selected: false});

Code should be placed in a background page. If you need it inside a content script you can pass a message to a background page, like so:

//content script
chrome.runtime.sendMessage({link: link});

//background page
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
    if(message.link) {
        chrome.tabs.create({url: message.link, selected: false});
    }
});

Leave a Comment