Detect whether a browser, a tab and which tab amongst all the opened tabs has been closed

Viewed 79

How to detect whether a browser has been closed, a tab has been closed and which tab amongst all the opened tabs has been closed ? Are there any events available to handle each one of the above cases in Angular/Javascript. Any information or sample code will be helpful and appreciated. Thanks!

1 Answers

You can detect it with onunload and onbeforeunload events. But you cannot prevent that event and continue your logic.

But remember, you can still trigger a "Your are leaving the page" confirmation

Related