1

open a popup window using window.open() on on html page

pop=window.open('pops.html','mypop');

when i go to new page how can i detect whether this popup still opened or closed using java script. Thank you

Suneth Kalhara
  • 1,116
  • 4
  • 16
  • 40

1 Answers1

0

You could use window.opener.methodYouWantToCall() to call methods in the window that opened the new window to talk to the opening window and tell it things like "I'm still open". you can read more here. You will have to make sure that the method exists in the window though. here is some pseudo code for how to handle it:

my_window = window.open(...);
my_window.opener.document.onUnload = function(){
my_window.opener.document.onload = function(){
my_window.opener.theWindow(a variable) = my_window;
}
};

(in new page):
function check(){
if(theWindow != null){
if(!theWindow.closed){
    // handle
}
} else {
setTimeout("check()", 1000);
}
}
Lysol
  • 1,547
  • 13
  • 27