Is there a way to detect tab close event to clear the localStorage
. I need localStorage
to share data across tabs. window.onbeforeunload
event works fine but it has 2 issues for me:
- It also fires on page refresh which I dont want.
- I don't need confirm box on tab close.
Like when window is closed the sessionStorage
is cleared. At same time I can clear localStorage
but don't know what event to bind to. I checked a few questions already available but none seems to address this issue there are workarounds by using flags for click on links and form submits but not a clean way to do it. Kindly suggest any solution for this.