From what I could find the window.open will return null when it fails to open. Something may be keeping the browser from opening additional windows a couple of times; maybe it is a popup blocker.
The actual loading of the url and creation of the window are done asynchronously.
https://developer.mozilla.org/en-US/docs/Web/API/Window.open
Answer from Joshua5822 on Stack OverflowFrom what I could find the window.open will return null when it fails to open. Something may be keeping the browser from opening additional windows a couple of times; maybe it is a popup blocker.
The actual loading of the url and creation of the window are done asynchronously.
https://developer.mozilla.org/en-US/docs/Web/API/Window.open
Popup blocking
In the past, evil sites abused popups a lot. A bad page could open tons of popup windows with ads. So now most browsers try to block popups and protect the user.
Most browsers block popups if they are called outside of user-triggered event handlers like onclick.
For example:
// popup blocked window.open('https://javascript.info'); // popup allowed button.onclick = () => { window.open('https://javascript.info'); };
Source: https://javascript.info/popup-windows
It is blocked by the browser. window.open is only not being blocked, when it is invoked by user action, for example in a click event, emitted by a native browser event. Also javaScript emitted events are being blocked, just like delayed setTimeout callbacks.
<a id="link" href="http://stackoverflow.com">StackOverflow</a>
<script type="text/javascript">
// Example (with jQuery for simplicity)
$("a#link").click(function (e) {
e.preventDefault();
var url = this.href;
// this will not be blocked
var w0 = window.open(url);
console.log("w0: " + !!w0); // w0: true
window.setTimeout(function () {
// this will be blocked
var w1 = window.open(url);
console.log("w1: " + !!w1); // w1: false
}, 5000);
});
</script>
Watch the Fiddle. I also tried it with the keypress event, but no luck.
window.open returns a valid reference to the new (or an existing named) window, or null when it failed to create a new window.
Try the next command after window.open with timeout, for example:
var myWindow = window.open('foo','_blank','menubar=no, scrollbars=yes, top=10, width=800,height=600');
setTimeout( myWindow.onload=function(){this.document.body.innerHTML+='bar';}, 2000 );
Do you have any extensions installed in the Microsoft Edge?
Try press Ctrl+Shift+N and it will open InPrivate browsing and see if the problem persist?
Did you observe this behavior in previous builds?
Does it happens in one specific website or in all JavaScript codes?
Try report it using feedback option and make sure include sample code or any data to help the Microsoft Edge team reproduce this issue.
Take a look at How to Report a Feedback/Bug to Microsoft Edge’s Team? - Microsoft Community
For IE10, window.open returns a NULL reference object if Enable Protected Mode is checked under Internet Options->Security->Security Level for this zone and the ZONE is different i.e. in my case local file opening a popup from Intranet.
window.open returns a reference object even if Enable Protected Mode is checked when yoursite.com opens someothersite.com in popup window i.e. Internet->Internet
You can use window.showModalDialog as a alternative or replacement for window.open method.
It is more secure then window.open. It will not allow user clicking the Parent page.
Example Usage:
var myFeatures = "dialogWidth:1060px;dialogHeight:550px;resizable:yes";
window.showModalDialog(url,window,myFeatures);
//Here window is an object, no need to assign or declare.
If you want more detail explanation see Here. //Fifth Question.