questhaven
Programmer
Hi there - Does anyone know if there is any way I can catch the window close event when someone clicks on the "X" window button?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<body onUnload="myCloseFunction()">
//this script opens a child window and assigns it's handle
//to a variable called mypopup. Then periodically checks
//the state of the popup window to determine if it has been
//closed.
var mypopup = window.open('popup.html', 'mypopup');
checkwindowstatus();
function checkwindowstatus(){
if(mypopup.closed){
//The popup has been closed, do some processing here
}
else{
//check again in one second
self.setTimeout('checkwindowstatus()', 1000);
}
}