Reputation: 4672
Friends
In our application, we have a parent window A , and then there is window B which spawns out of window A and then window C spawns out of window B and then several other windows spawns out of window C When I logout from window A , only window B gets closed , it DOES NOT close window C and its childs
The script that is currently in use is as below.
function Close(frm) {
var win;
if(window.opener)
{
win = window
}else if(window.parent.WinObjectArray)
{
win = window
}
else
{
win = window.parent;
}
if(!win.parent.WinObjectArray)
win = win.parent;
if(frm=='logout')
{
if(window.WinObjectArray !=null && window.WinObjectArray!=undefined)
{
for(i=win.parent.WinObjectArray.length-1;i>=0;i--)
{
if(!win.parent.WinObjectArray[i].closed)
win.parent.WinObjectArray[i].close();
}
return ;
}
}
var closeWinArray = new Array();
closeWinArray[0] = window;
if(window.WinObjectArray !=null && window.WinObjectArray!=undefined)
{
for(i=0;i<win.parent.WinObjectArray.length;i++)
{
var openerFnd = false;
for(j=0;j<closeWinArray.length;j++)
{
if(!win.parent.WinObjectArray[i].closed && win.parent.WinObjectArray[i].opener == closeWinArray[j])
{
closeWinArray[closeWinArray.length] = win.parent.WinObjectArray[i];
openerFnd = true;
}
else if(win.parent.WinObjectArray[i].closed)
{
openerFnd = true;
}
}
if(openerFnd){
win.parent.WinObjectArray.splice(i,1);
i=i-1;
}
}
}
if(window.WinObjectArray !=null && window.WinObjectArray!=undefined)
{
for(i=0;i<win.parent.WinObjectArray.length;i++)
{
if(win.parent.WinObjectArray[i] == window)
{
win.parent.WinObjectArray.splice(i,1);
break;
}
}
closeWinArray.splice(0,1);
for(i=closeWinArray.length-1;i>=0;i--)
{
if(!closeWinArray[i].closed)
closeWinArray[i].close();
}
}
for (i=0;i<WindowArray.length;i++){
if (! WindowArray[i].closed) {
WindowArray[i].close();
}
}
}
Upvotes: 0
Views: 487
Reputation: 2674
Just have window A become the liason for all your window spawns. Its easy to call to the parent to write up a new window for child processes/windows. So if you route all your window functions to and from the parent you will no longer have this issue. The parent [A] will have permission and full control of all child windows under this setup.
Upvotes: 2
Reputation: 16060
I think Window A has no permission to clode Window C and the child Windows of C.
Try the following: Create a Javascript for the event onClose(). Attach this to Window B. In that method close the children of B. The children of B shoud have the same kind of onUnload() oder onClose() listener and close the windows, created by them.
Upvotes: 0