I have a web application that pops up another window.
If the person closes the main browser window, I need to close the child window as well.
Is this possible? If so, how?
I have a web application that pops up another window.
If the person closes the main browser window, I need to close the child window as well.
Is this possible? If so, how?
When you call window.open(), the return value is a handle to the new window that was created. Using this, you can keep an array of windows you have opened, and then call close on them within an unload event handler:
var win = winodw.open(URL, title, options);
window.MyOpenWindows.push(win);
Later, in a function registered for the unload event:
function closeWindows(){
for (i=0;i<window.MyOpenWindows.length;i++)
{
window.MyOpenWindows[i].close();
}
}