I can’t seem to access the window.history.state object when my popState is triggered in Safari 5 (the page goes back). This code works perfectly in Chrome 19 and Firefox 12.
window.onload = function() {
window.setTimeout(function() {
var original = window.location.href;
window.addEventListener("popstate", function(e) {
if (window.history.state !== null) {
var type = window.history.state.type;
var page = window.history.state.page;
//custom Ajax function below
getContent({type:type, page:page, category: category}, '/' + type + '/' + page);
} else {
window.location = original;
}
}, false);
}, 1);
}
console.log(window.history.state) in Safari 5 returns ‘undefined’.
window.history.stateis only available in some browsers. It’s not part of the spec per se.