2

I need to trigger if the user close the browser to turn the status of the user from online to offline after the browser session ended by 15 minutes.

  • Does this answer your question? [How can I handle browser tab close event in Angular? Only close, not refresh](https://stackoverflow.com/questions/34129319/how-can-i-handle-browser-tab-close-event-in-angular-only-close-not-refresh) – Eggcellentos Jul 02 '20 at 08:30

1 Answers1

0

If you want to implement in Angular use

@HostListener('window:beforeunload', ['$event'])
handleBeforeUnload(event) {

// add confirm box and place your code accordingly }

and implement ComponentCanDeactivate.

URL:- https://medium.com/better-programming/angular-how-keep-user-from-lost-his-data-by-accidentally-leaving-the-page-before-submit-4eeb74420f0d

Hope this helps you.

Rahul
  • 154
  • 1
  • 9