window.popstate only going back 1

Viewed 72

When using onpopstate, and clicking BACK in the broswer, I'm only able to go back once and the forward button is disabled. What am I doing wrong? (event.state doesnt change after one back click, returns the same thing on subsequent presses)

Been using the advice from https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate to implement states to fetch new content and cache it on going back in the browser.

window.onpopstate = function(event) {
  doSomethingWithContent(event.state);
};

history.pushState(data, title, url);
0 Answers
Related