• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Child windows not getting closed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic