From a parent window check if its child window is closed - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window Load

Description

From a parent window check if its child window is closed

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from  w w w. jav  a 2 s.com
var intervalID, childWindow;
childWindow = window.open("http://www.google.com");
function checkWindow() {
    if (childWindow && childWindow.closed) {
        window.clearInterval(intervalID);
        console.log('closed');
    }
}
var intervalID = window.setInterval(checkWindow, 500);
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials