This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
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)