Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem closing unknown amount of windows

Status
Not open for further replies.

khennes02

Programmer
Joined
Jun 22, 2004
Messages
6
Location
DE
Hi everyone,

I have built a page that monitors a number of other Programmes.
My problem is that I want to create a logout Button on all the windows.
I tried to put on each window a onUnLoad="window.opener.close();" and then only somehow close the last window. This does somehow not work properly. I think it is because two or more windows where opened from the same script (name).
Is it possible to close a window that has nothing to do with the current Window.
Can somebody give me a tip how to solve this problem.
 

>> Is it possible to close a window that has nothing to do with the current Window.

If it has nothing to do with the same window, then you have no way of referencing it to close it.

Maybe I've misunderstood your problem. Can you define it a bit more clearly?

Dan
 
I have got a on the Start Page an Iframe for each system to be monitored.
It is possible to have links from within these Iframes to open a second Monitor page that is again built with little Iframes.
There can be an unknown amount of Monitor Pages, that have could been open from any one of the pages within the Iframes.
Now I am trying to create a button that closes all the monitor pages an reloads the Start page with different properties.
Here is what I tied, but it somehow does not want to work.
It does not close the windows.
<script type="text/javascript">
var i=1;
var winname="";

for (i=1;i<= <?php echo $_SESSION['page']; ?>; i++)
{
winname = "page"+i;
if(winname && winname.closed == false)
{
winname.close();
}
}
</script>

I increase the variable $_SESSION['page'] by one each time a form gets loaded, so I know the max number of windows that could have been opened.
I also gave all the Windows names "page"+$_SESSION['page'].
What could be the reason that this does not work, or does anybody have a better Idea.
Thanks Kai
 

Check out my FAQ: faq216-4783

If you use this in all iframes to open the windows, then it might work for you.

You might have to store childWindowHandles in the main parent / opener window and reference it accordingly, however.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top