You might be able to use history.js . It should give you an API that will behave consistently on all major platforms (although it is possible that it does not address this particular problem, you will have to try to find it out).
However, in my opinion, the best way to deal with this (and other related problems) is to develop your application in such a way that these problems do not matter. Watch your expression, and not rely solely on the state object in the story stack.
Track which page your app is showing. Track it in a variable - separate from window.location . When a navigation event (including popstate) occurs, compare your known current page with the next page request. Start by figuring out if a page change is really needed. If so, render the requested page and call pushState if necessary (only to call pushState for "normal" navigation - never in response to the popstate event).
The same code that popstate handles should also handle your normal navigation. As far as your application is concerned, there should be no difference (besides the fact that regular nav includes a pushState call, while navstate-nav does not work).
Here is the main idea in the code (see live example in jsBin )
If you look at the jsBin example, you will see that the _renderPage function _renderPage called every time the application asks for a transition to a new page - be it because of a popstate (for example, the back / fwd button) or because of a call to goTo(page) (for example , user actions of any kind). It is even called when the page loads.
Your logic in the _renderPage function can use the currentPage value to determine "where the request goes." If we exit the external site, then currentPage will be null , otherwise it will contain the path to the page currently being displayed.
source share