I am using javascript window.open method to open lets say http://www.google.com [its always going to be some external url]
I have stored the reference of the window object in a variable, the problem is that variable never gets null on the parent page and I am not able to alert the user that the pop up has been closed.
Here’s the code
var winFB;
var winTWt;
var counterFB = 0;
var counterTWT = 0;
var timerFB;
function openFB() {
if (counterFB == 0) {
winFB = window.open("http://www.google.com");
counterFB = 1;
}
if (counterFB > 0) {
alert(winFB);
if (winFB == null) {
counterFB = 0;
clearTimeout(timerFB);
alert("Window Closed");
}
}
timerFB= setTimeout("openFB()", 1000);
}
I can not put any javascript code on the pop up/child window.
Hope someone can help me on this
The window variable doesn’t get nulled out when it’s closed, however its
.closedproperty istrue, so just change your check to be for that property, like this:Also note the
setTimeout()change, pass a function in whenever possible (almost always) rather than a string, you’ll have a lot less problems with scoping.