After you open
the new window (we'll call it newWindow
), do this:
newWindow.blur();
window.focus();
This is usually called a "pop-under." Opening the window won't usually work unless it's initiated by a user action like a mouse click, due to pop-up blockers built into most web browsers.
Just remember to get a handle to your new window when you open it.
var newWindow = window.open(...);
Also, if your pop-under is loading content from another domain, you'll need to do the blur
/focus
thing before you send the window to its destination, otherwise you'll run into the same-origin problem.
HTML:
<a href="xxx" target="_blank" onclick="return popUnder(this);">
JS:
function popUnder(node) {
var newWindow = window.open("about:blank", node.target, "width=500,height=500");
newWindow.blur();
window.focus();
newWindow.location.href = node.href;
return false;
}
This is typically a browser preference. But if you can somehow get a hold to the other window with javascript (maybe by hooking up the onclick event and open the link with window.open you could do the typical pop-under trick:
otherWindow.blur();
window.focus();