I've read several question/answers on Stack Overflow and Googled the issue, I can't seem to get the event.state
to come back with anything but null
.
I got that it wont work with the jQuery event, but when I do something like this:
window.onpopstate = function (e) {
console.log(e.state)
}
With something along the lines of a jQuery.ajax success calling
history.pushState({ lastUrl: data.State }, data.Title, data.UrlKey);
Neither Chrome (v19) or Firefox (v12) return anything but null? Am I missing something? Is it just not fully implemented?
e.state
refers to the second last state that was pushed. You need to have pushed state at least twice for e.state
to not be null
. This is because you should save the state when your site is loaded the first time and thereafter every time it changes state.