Closing child windows
<p>Friends</p>

<p>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 </p>

<p>The script that is currently in use is as below. </p>

<pre><code> 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 &amp;&amp; window.WinObjectArray!=undefined)
    {
       for(i=win.parent.WinObjectArray.length-1;i&gt;=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 &amp;&amp; window.WinObjectArray!=undefined)
    {
        for(i=0;i&lt;win.parent.WinObjectArray.length;i++)
         {
           var openerFnd = false;
             for(j=0;j&lt;closeWinArray.length;j++)
               {
              if(!win.parent.WinObjectArray[i].closed &amp;&amp; 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 &amp;&amp; window.WinObjectArray!=undefined)
    {
    for(i=0;i&lt;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&gt;=0;i--)
    {
    if(!closeWinArray[i].closed) 
    closeWinArray[i].close();
    }
    }
        for (i=0;i&lt;WindowArray.length;i++){
        if (! WindowArray[i].closed) {
        WindowArray[i].close();
        }
    }
}
</code></pre>
