I have a three-step login form that shows / hides the content on the page as it moves. When the user goes from step 1 to step 2, I call the following:
var stateObj = { foo: "bar" }; history.pushState(stateObj, "", "");
And I see a browser enable button.
Now I am trying to catch the back button so that I can hide / show the content (for example, back to step 1) respectively.
How can I identify the browser button in this scenario? I don't want the url to change, I just want to call some JS function when the user hits back. I focus on modern desktop / mobile browsers.
source share