I’m opening a new browser window from my site for some of the members. However, some may later close it, or it might have initially failed to open.
Is there a snippet of fairly plain Javascript that can be run on each page to confirm if another browser window is open, and if not, to provide a link to re-open it?
[clarification:] The code to check is a window is open would be run on other pages – not just in the same window and URL that opened it. Imagine a user logging in, the window (tries to) open, and then they surf around in the same tab/window (or others) for some time before they close the 2nd window (or it never opened) – I want to be able to notice the window has been closed some time after the initial attempt at opening/after it’s closed, so I’m not sure that checking the javascript’s return from window.open() (with popup_window_handle.closed) is easily used, or indeed possible.
This excellent, comprehensive article (‘Almost complete control of pop-up windows’) should answer all your questions about javascript popup windows.
‘JavaScript 1.1 also introduced the window closed property. Using this property, it is possible to detect if a window has been opened and subsequently closed. We can use this to load a page directly into the opener window if it still open for JavaScript 1.1 enabled browsers:’
Addition: You can get the window handle back in another page by referring to the popup’s name this way:
I guess in your case you should think about a consistent way to create all the names of the popup windows throughout the entire application.