Friday, January 17, 2020

Catch the back button event in JavaScript?

window.onhashchange and popstate are ways to catch the event that is triggered by window.history.back(); and history.go(-1); which occur when the back button is pressed. Yes, if you make that -1 a -2 and call it yourself in JavaScript you'll take the user back two pages.

No comments:

Post a Comment