0

I have a simple history.pushState() in my code:

history.pushState(null,null,data["url"]);

And it works perfectly, but when I click the browser's back button after running history.pushState(), only the URL bar changes; the page it's self does not reload.

I reviewed several StackOverflow questions where this problem had been presented but none of the solutions in these answers solved my problem. I do not have any other history calls in my code, but for an identical call elsewhere. I'm not using window.onpopstate either and would prefer not to, unless absolutely necessary.

I noticed that in this answer, the author suggested checking the address bar for changed every 500ms, then loading new content. This seems like a rather in-elegant solution and, though I would if there is no other way, I'd prefer not to use it (I'm worried about the effect it might have on performance).

Community
  • 1
  • 1
Laef
  • 1,086
  • 2
  • 11
  • 27

1 Answers1

0

Well, for start - why not using onpopstate?* this is the right way to do it, as far as I understand.

_

*or, bind('popstate')

anysite
  • 148
  • 1
  • 12