0

Hi i have tried the below event to detect but sometimes it doesn't fire the event, while closing the tab or Browser.

$window.onbeforeunload
  • this will help you:-https://stackoverflow.com/questions/5004978/check-if-page-gets-reloaded-or-refreshed-in-javascript – Parth Raval Dec 15 '17 at 11:57

1 Answers1

1

if you want only browser close do something and you do want when refresh page yuo can use this code:

   window.onbeforeunload = function () {
    if (performance.navigation.type == 1) {
        localStorageService.remove("authorizationData");
    }
}
miladdn131
  • 72
  • 5