History API Question
-
How does Discourse get the history API to update the URL for every reply, but still allow the back button to take the user to the previous page? This would be very useful for a project I'm working on, but I can't seem to phrase my search appropriately to find the answer on Google.
-
It's
window.history.pushState()
for the back button andwindow.history.replaceState()
for scrolling.
-
I experimented with replaceState(), but it seemed to be screwing with the history of previous pages. I'll try again tonight if that's the correct method.
Thanks for your help.
-
There is some info and a demo on http://diveintohtml5.info/history.html, if you’re interested.
-
That looks very useful; I'll check it out this evening.
-
The replaceState() method is working correctly now. I'm not sure what I was doing wrong before.
Thanks again.