I stuck in the problem. I am working on website where I have main page, we can say it Parent page. And through that I am redirecting to other pages in new tab only, to them we can call as Child Page. My question is that, how I can detect on child page that the parent page tab has been closed by user? I don't know where I can use Javacript or PHP to detecting on every child page. I want to get the detection on real time. I mean, I do not want to execute function in every 1 minute which check for the value to detect that the parent page was closed.
Asked
Active
Viewed 793 times
-1
-
I saw that here, people are busy to editing the grammatical mistake of qustion more than supporting by answers. well, i got the answer, its not clear, but it clear my point of view. thanks – shoaib May 05 '16 at 05:02
1 Answers
0
You can capture the window.onClose event in the parentwindow and send a value to the child window when this happens (set a variable in the child window). Note that the only way to get a reference to the child window is through the return value of window.open(). window.beforeunload might be more widely supported, but it also fires when you go to a different page of your website in the parent page-- this is actually more useful in some cases, especially if the user goes to a new website using the same tab. See How to capture the browser window close event?.

Community
- 1
- 1

Feathercrown
- 2,547
- 1
- 16
- 30
-
thank you for your answer.. yes, i knew that i can send value to child page on unload of window. But i had problem that,i will need to call a function again and again on child page to detect the value from parent page. i will use same method anyway... thank you for your answer.. – shoaib May 05 '16 at 05:04
-