aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Child windows not getting closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Child windows not getting closed" Watch "Child windows not getting closed" New topic
Author

Child windows not getting closed

Arun Manivannan
Greenhorn

Joined: Jun 14, 2005
Posts: 5
Hi,

I have a very strange problem in my current project. The project layout looks like this. There is a tree menu on the left side ( no frames) and a login screen on the right. When I click an node in the menu, a new pop-up window comes for each node.

I have a "Close All" button in the login screen which is supposed to close all the child windows. What I did was to store all the window.open() instances into a Javascript array. THen looped through the array's length and called the window.close(). Its working fine except for one situation.

The logic behind the Expanding and Contracting of menu's is written in scriptlets (this project is being maintained since 2000). So, every time I expand a tree, the page gets reloaded again carrying the 'Expand' parameter.

The Problem : When I click some leaf nodes to open some child windows (say 3 pop-ups) and then try to expand a new tree (+) (i.e. reload the page) to select a new node, only the last opened nodes (after the new tree has been opened) is taken as child nodes.

The previously opened 3 nodes is not at all considered. So, my "close all" button closes only the last opened windows.

Is there any solution to solve this problem other than coding the menu in Javascript?

Arun


SCWCD 1.4
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If the page gets refreshed/reloaded you destroy the JavaScript object holding the windows so you are not able to close the windows. There is no way for the parent to maintain them unless you set the whole page into a frameset and have a hidden frame where the windows are called from.

Eric
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
There is a fun solution for this, that works in IE only (and may not work in some versions)
The trick is in using IE bug (or feature?) that custom properties assigned to window.location are not getting removed when window is reloaded, i.e. if you open a window using:
window.location.wnd = window.open("something","something");
, then reload the page, and than call
window.location.wnd.close()
, it will close that new window. The same way you can keep there an Array of windows, if you want.

Another solution is to name each window diferently and every time page reload send list of names to the server and get it back in the same page. Then you can loop throught the names, and try to open a page with the only line self.close() for every window name you have. (Can be very messy)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Child windows not getting closed