How to pick up event that closes the browser?



  • I'm trying to clear my siteStorage before the window is closed and I tried to use window.unload and also window. unbeforeload. However, when using the same they clean the siteStorage if I just reload the page.

    How can I be firing a function only when closing the browser? Please.



  • It is not correct to use localStorage if you want to clean it when closing the Browser.

    The right approach is sessionStorage, which behaves similar to an application session, which, as soon as it is closed, the session is closed.

    See more at:

    https://pt.stackoverflow.com/questions/19384/diferen%C3%A7as-entre-localstorage-vs-sessionstorage




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2