0

Think of a webpage that has a list of website links. When I click on a website, the website opens in another tab and a timer starts counting the time. This time counting should end when I am closing the tab of previously opened website.
(Sounds weird?!)
I have tried searching over internet for a long time, but everywhere I get the answers for "Detect browser or tab closing while staying in the same tab", and this has nothing to do with another tab.
I am trying to make connection across tabs, so that, I can stop the time counting automatically when a tab is being closed.
Any kind of help will be appreciated :)

  • Not sure why is the issue with letting the timer go all the way and just try to close the tab if still open. – Gi1ber7 Oct 20 '20 at 17:26
  • Actually, a new tab opens using target='_blank' ,along with the website link that was clicked in the root tab(the webpage i have created). So, we have now two tabs. First is my personal webpage, and second tab is the website that was clicked. The confusion you said about... "just try to close the tab if still open". But, i have the root tab opened always. I will close the new opened tab and timer on my webpage should somehow detect this event. Thanks – Bappy100 Oct 21 '20 at 13:59
  • "the timer go all the way"...this is because i am not closing my webpage, timer starts counting the time in my webpage. Just closing the other tabs that were opened afterwards. Hope that makes sense. – Bappy100 Oct 21 '20 at 14:05
  • A possible solution could be (From your "parent-tab") use another timer to verify if the other child-tabs still exists and if not then you can terminate your main "timer" for that child-tab. The reason is that I don't think that is possible from the "child-tab" to notify the "parent-tab" that it was closed because the inherent properties of a browser. – Gi1ber7 Oct 21 '20 at 14:19
  • "verify if the other child-tabs still exists"....can you please describe how to do that? Or, any resource to learn about this particular technique? – Bappy100 Oct 21 '20 at 14:23
  • https://stackoverflow.com/questions/1760250/how-to-tell-if-browser-tab-is-active – Gi1ber7 Oct 21 '20 at 14:42
  • 1
    I will try out the solutions there. Thank you @Gi1ber7. – Bappy100 Oct 21 '20 at 14:52

0 Answers0