Instead of opening a window from JavaScript, use JavaScript to update the href link and then click on the link. This way you get the same behavior as the user by clicking on the link.
Add a link to your page with the id and target="_blank" . When you want to open a new window, refresh the href this link, and then invoke a click like this (from here ).
function clickLink(link) { var cancelled = false; if (document.createEvent) { var event = document.createEvent("MouseEvents"); event.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); cancelled = !link.dispatchEvent(event); } else if (link.fireEvent) { cancelled = !link.fireEvent("onclick"); } if (!cancelled) { window.location = link.href; } }
source share