The following code should cause an alert of \'1\', but instead does nothing.
window.onpopstate = function(event) { alert(event.state.a) }
history.pushState({
In order to force trigger event you needs navigates between two history entries for the same document and to call proper history method.
Calling history.pushState() or history.replaceState() just, it not will trigger popstate
event. Also, check the history.pushState()
params.
So you can to do it:
window.onpopstate = function(event) { alert(event.state.a) }
history.pushState({a: 1}, "")
history.back() //add history entry
history.back() //add history entry
history.go(1)
Here something more elaborate :)
page