I'm testing new JS/HTML5 history
methods. On subpage load I have an event changing the URL and history state:
$("#content").load("./content/map.txt", function() {
history.pushState({}, "map", "map.html" );
window.history.go(1);
});
Now when the user clicks back button the history.state
and the URL changes, but without loading the previous page (without refreshing the current URL).
I tried to add a manual refresh on the history.state
change, I found something like this:
window.addEventListener('popstate', function(e){
if (history.state){
self.loadImage(e.state.path, e.state.note);
}
}, false);
but it doesn't work.
Try this:
window.onpopstate = function(event) {
if(event.state["map"] == "some_state") // get the current state from the event obj
location.reload(); // reloads the current page to clear ajax changes
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.