Reputation: 994
I used window.onunload
and tried window.onbeforeunload
but both are clearing the data on tab close as well. I want the data to remain when tab is closed and it should clear it out when the entire browser is closed. Any solution on this?
Upvotes: 1
Views: 1440
Reputation: 91
You should take a look at sessionStorage: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#sessionStorage
Upvotes: 1
Reputation: 118
That's not possible. Unluckily there is no event fired when closing the entire browser (at least not in Chrome, Firefox and Internet Explorer).
You will have to find another solution to achieve what you need :(
Upvotes: 1