UPDATE: as of version 41 of Google Chrome, initMouseEvent seems to have changed behavior.
this can be done by simulating ctrl + click (or any other combination of keys / events that open the background tab) for a dynamically created element a with its href attribute set to the desired url
In action: fiddle
function openNewBackgroundTab(){ var a = document.createElement("a"); a.href = "http://www.google.com/"; var evt = document.createEvent("MouseEvents"); //the tenth parameter of initMouseEvent sets ctrl key evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null); a.dispatchEvent(evt); }
tested only on chrome.
Amro Jul 09 2018-12-12T00: 00Z
source share