Reputation: 31
I'm opening a child window to another site where I don't control the content. I've implemented the pattern I found here of using a set timeout to check the window.closed property.
I've found this confirmed bug report for edge. Edge Issue Report
Here is the code as it sits now.
var myWindow = window.open(
url,
'myWindow',
'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes');
// Check for the myWindow to close. When closed attempt to validate.
var timer = setInterval(checkWindow, 1000);
function checkWindow() {
debugger;
// Try Block to catch our popup window being blocked
try {
if(myWindow.closed) {
clearInterval(timer);
//do stuff here
}
}
catch(e) {
clearInterval(timer);
//handle blocked popups and other stuff
}
}
when it hits the debugger step and I check myWindow.closed it is always true. In chrome it is false until I actually close the child window. Is there a work around or different pattern people are using?
Upvotes: 3
Views: 2232
Reputation: 159
Take into account, that window.closed always returns true, if the newly opened URL isn't from the same origin / domain as it is opened from:
Upvotes: 3