3

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!

  • 2
    Does this answer your question? [Detect browser or tab closing](https://stackoverflow.com/questions/3888902/detect-browser-or-tab-closing) – Asaf Sep 25 '20 at 10:31

1 Answers1

0

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

Zortext
  • 566
  • 8
  • 21