以下代码集合关注新选项卡,而不是开启者。
function openChildtab() {
var win = window.open("https://www.amazon.co.uk/gp/product/B01J90O0N4/ref=sv_kinc_2", "_blank");
if (win) {
window.focus();
} else {
alert("Please allow popups for this website");
}
}
<a href="#" onClick="openChildtab()">Open New tab</a>