In many web portal applications, there are lots of popup windows get opened when users navigate to some links or there may be some popups window providing some relevant information. These popups may get opened when some specific events occur on the site or may be opened by user’s click.
In this flow of site, at a particular time there can be lots of child windows/popups opened and user may not want to close these individual windows when user wants to move out of the site either by signing off/logging off or by just closing the main window/page.
So to close all those child windows we need to handle the events fired when main window gets closed i.e. unloaded or when user clicks on the LogOut button.
But to achieve this, first we need to store the child windows’ identity so that they can be closed at the required time.
protected void Page_Load(object sender, EventArgs e)
var winArray = new Array();
winArray = window.open(“page1.aspx”, “Page1”);
winArray = window.open(“page2.aspx”, “Page2”);
Define OnUnload event of the main page as:
And in the click event of the LogOut button:
//do your operation on loggin off
This will close all the child windows.