Skeellz
Skeellz

Reputation: 71

How to implement a "back" button on an ajax loaded page

I don't know how this is possible but I've seen it in big sites like Facebook and Twitter. I'm using jQuery in prototype to load pages (Ajax-wise). So I want to know how to implement a 'back' button such that when a user clicks back on his/her browser he/she is taken back to the previous page. I believe since it's Ajax, the page is not actually changing so in what way this can be done? Thanks in adv

Upvotes: 2

Views: 5297

Answers (1)

Aᴍɪʀ
Aᴍɪʀ

Reputation: 7803

They are using pushState and History APIs.

If you want to do that, you have to have your own code to manage the state of the page. Push it in the history stack and listening to the proper events, restore the state of the page based on the popped state when the back button pressed.

More info about pushState and history API.

Also, take a look at this question and code snippets posted.

Upvotes: 2

Related Questions