Reputation: 75
I have been looking for a way to detect a page reload, but can't seem to find a viable solution that works.
I looked at this for reference (http://www.tedpavlic.com/post_detect_refresh_with_javascript.php), but did not work on my end. Is there an effective way to detect this?
My overall goal is to detect a page reload so that I can clear my sessionStorage.
Upvotes: 0
Views: 910
Reputation: 371
I agree with Aaron McGuire's comment--rather than trying to detect a page load, then clear session storage, it'd be easier to clear session storage on page load. You could insert something quick like this at the top of your code:
window.onload = function() {
sessionStorage.clear()
}
Upvotes: 2