AJAX back button solution similar to facebook

1.2k views Asked by At

Im new to ajax, jquery and javascript. When i learnt ajax and jquery, i also learned about back button issues and of course i learnt it too. But this solution uses the # anchors. But I want to change the url to the actual page just like to facebook. If you use facebook, you may have noticed that when you click an image, the url gets changed to the url of image but the page doesnt navigates away.

If Any one know about facebook like solution then please answer it.

2

There are 2 answers

1
A.M.K On

You are looking for Hash Navigation, also known as Fragment Navigation. Google has a very good article on this.

Here is a demo from them: http://gtv-resources.googlecode.com/svn/trunk/examples/location-hash-html.html

0
divaidee On

I know you don't want to hear this, and I'm also new to AJAX and I'm also working on this right now, but i can give you the advise to use hashes first. Why?

Because hashes are accpted in any browser. If i were you I would now work out a solution that can be used with or without ajax (so there's a 'normal' navigation if ajax is not available, because web crawlers don't understand javascript).

If you have successfully worked out your solution, THEN you can add some functions to use the javascript pushState() (or replaceState()) method to manipulate the url. Don't underestimate this and use hashes at the beginning.