Your code does not trigger a pop-up message because the pushstate command tells you which page you are on now.
window.onpopstate = function(event) { alert(event.state.a) } history.pushState({a: 1}); history.pushState({a: 2}); history.back()
The above code will work.
Heres the fiddle: http://jsfiddle.net/WNurW/8/

As you can see in the above image:
(1) Here you entered a page or a violin, then you want to click State, which will add a new link to the history chain.
(2) When you click on a state, you will add another back-click to the story, but it will also move the current location to the โstoryโ to your new state. Therefore, returning, will not give you the story that you think you are getting about, it will give the previous one.
(3) You need to go to the โnewโ page or click another state of the story to return to the state created in step (2).
Andrรฉ snede kock
source share