I have a very strange problem , please don’t ask me why do I need this…
I have a page1. Page1 has a link which opens new window (page2) using window.open function.
chatWindow is a handler of child window with returns from window.open function.
Now I’m moving from page1 to page3 (by link <a href="...." target="_self">Some Text</a>). And I need to check on the page3 if page2 is close or open.
How to pass handler chatWindow from page1 to page3?
Thank you in advance!
On page2 and page3, you can refer to page1 using
window.opener. In page1, you can define a method which checks whether page2 is still open or not:window.openreturns an instance of the new window, andnullif the window has been closed.Note that you can only read properties from windows if they’re at the same domain. If they’re from different domains, you can enable communication using the
window.postMessagemethod.Assuming that they’re at the same domain, you can use the following code (concept code):
I have used global variables for the ease. A better implementation can consist of a namespace: