You can do this manually with CTRL
+ Left-click
. Now you can basically simulate this with event.initMouseEvent
which has all the properties of the click event. Including the CTRL
+ Left-click
event.
The only downside is:
his method may only be called before the MouseEvent has been
dispatched
This means you have to cancel the default anchor event and create a custom event which also custom fires.
With event.preventDefault();
you can cancel the default anchor event from happening:
$('a').click(function(event)
{
event.preventDefault();
openNewBackgroundTab($(this));
});
Where i will give the clicked element as parameter to the custom event creator(this is used to get the clicked href).
Where we will create a whole new "floating" element, with a custom event and where we manually have to fire the event:
function openNewBackgroundTab(elem)
{
var a = document.createElement("a");
a.href = elem.attr('href');
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null);
a.dispatchEvent(evt);
}
Note that jsFiddle doesn't support external links
Source of this method: Open a new tab in the background?