I\'m trying out the HTML5 history API with ajax loading of content.
I\'ve got a bunch of test pages connected by relative links. I have this JS, which handles clicks on
This is an older question but there is a much simpler answer using native javascript for this issue.
For the initial state you should not be using history.pushState
but rather history.replaceState
.
All arguments are the same for both methods with the only difference is that pushState
creates a NEW history record and thus is the source of your problem. replaceState
only replaces the state of that history record and will behave as expected, that is go back to the initial starting page.