I had a web page that would list a bunch of items. Users needed to be able to click the “add” button and open a pop-up window that would let them choose an item to add to the list. The pop-up window displayed a hierarchy of choices so users had to click on it several times in order to make their selection.
When the user made their selection I needed the pop-up window to close and then refresh the original window. I found several things that worked on some browsers but not others. In the end I found something that seems to work on most browsers.
The code to close the current window is straightforward:
The code to refresh the parent is:
There are several other things that should work, but this seems to be the best way to make it compatible with different browsers.
In the end I created a variable called closeWindowString and bound it to the onLoad attribute of the body tag of the pop-up page. The string is normally blank. When the users clicks the select button the hyperlink is triggered. This causes the server to do it’s job and sets the closeWindowString to: