Check if the child window is open from parent window

Discussion in 'JavaScript' started by magnon, Feb 15, 2009.

  1. #1
    Hi,

    how can I check if the child window i created is still active or if it is closed?
    hopefully that it would work on IE and FF
     
    magnon, Feb 15, 2009 IP
  2. gnp

    gnp Peon

    Messages:
    137
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    when you create it you need to assign the window object to a variable

    
    var win = window.open(.....);
    
    Code (markup):
    now, since you have a reference to the window object, you can check the property closed
    
     if (win.closed)
    	alert('closed');
     else
    	alert('still open');
    
    Code (markup):
    ref: http://www.w3schools.com/htmldom/dom_obj_window.asp

    hope this does the trick for you ;)
     
    gnp, Feb 16, 2009 IP