Thế Hải Nguyễn Thế Hải Nguyễn - 2 months ago 8
Javascript Question

How to know user reload page by javascript

I stored a variable in sessionStorage. When I reload the webpage, sessionStorage don't set this variable to null. I must close the window and open a new one to do this. So, How can I know user reload page by javascript, I need sessionStorage set to null when I reload page


As suggested by @sideroxylon


This will fire whether the user reloads the page or navigates away.