I have a button that needs to open a new window as a popup (under the parent page). In IE/Firefox, it works fine, but in chrome the popup appears over (on top of) the parent
This is the fix you can use for Chrome (tested on lastest v.40 on 29/01/2015).
This won't open a window popup but a new tab and keeps on main tab focused(no more keeps focus on main tab on chrome v.43>).
To avoid popup blocker, you need user interaction, use specifically mousedown or mouseup event, click will throw a popup blocker warning.
document.addEventListener("mousedown", tabUnder);
function tabUnder() {
var a = document.createElement("a"),
e = document.createEvent("MouseEvents");
a.href = "http://testit.com"; //the URL of 'popup' tab
e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null);
a.dispatchEvent(e);
document.removeEventListener("mousedown", tabUnder);
}
-jsFiddle-