Dear All,
i am having a parent window
say parent.aspx
here i am creating child windows in javascript
like this
-
var myChild = new Array();
-
-
function MenuPopUp(url,width,height,left,top)
-
{
-
if (width == 0)//code to close all the open windows
-
{
-
-
var len=0;
-
for (i=0; i<myChild.length; i++)
-
{
-
if (myChild[i].closed == false)
-
len = len+1;
-
//alert(myChild[i])
-
}
-
//alert(len);
-
-
if (len >0) {
-
-
if (len == 1)
-
{
-
alert(" Switch from Company - Closing the open Window ") ;
-
}
-
else
-
{
-
alert(" Switch from Company - Closing all "+ len +" open Windows ") ;
-
}
-
-
for (i=0; i<len; i++)
-
{
-
if (myChild[i].closed == false)
-
myChild[i].close();
-
}
-
}
-
relocate(url,"s_company_name");
-
-
}
-
else// code open newe window and assign to the array
-
{
-
var Children ;
-
Children = myChild.length;
-
//alert(Children);
-
myChild[Children] = window.open(url,"","width=" + width +",height=" + height +",top=" + top + ",left=" + left + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no");
-
}
-
}
-
this function will open a new window in else part and closes the existing windows in the if part
and for each window i am opening i am referencing/assigning it[window] to a array object
so while doing some action in the main page , i need to close the child windows , so i can directly close by looping though the array and close the windows.
but in my main page [parent] page i have implemented a page refreshing logic
according to this the page will refresh after 500 secs
so in this following scenario the certain open windows become orphan
1) opening 2 new windows at 10th sec
2) wait until the page refreshes [say 500]
3) after 500 sec open another window
4) now do the task where you need to close all the child windows
5) the already opened 2 windows left open as orphans
this is why because while refreshing the javascript variable [myChild] is being reset and all the values contained in the variable is destroyed.
the windows opened will have no reference
Question:
so now i need to pass this array object to server[on unload event] and save the object in the session variable and retrive and restoring it to the array variable while the page loads again
so i may be having reference to all the child windows opened..
please give me solution
Thanks,
Raj