0

after the user logged in, the project-url is root/inside/. The site has 4 different main-sections, which will be displayed in a div via Ajax. The url does not change, after clicking on the links. How can i do it, that the url changes like this after clicking on the links for the main sections:

root/inside/my_account

root/inside/part_one

root/inside/part_two

root/inside/part_three

I would like to use that, because when the user is at one section and uses the back-button in the browser he is at the root. That's not user likely...

Thanks-

Reporter
  • 3,897
  • 5
  • 33
  • 47
Torben
  • 5,388
  • 12
  • 46
  • 78

3 Answers3

0

Maybe this will help: History API: http://html5demos.com/history

bububaba
  • 2,840
  • 6
  • 25
  • 29
0

The first solution is quite obvious: don't use ajax if you don't really need it and call instead the URL you're loading via ajax.

Anyway using ajax a solution is pushState method available on window.history object with HTML5: http://badassjs.com/post/840846392/location-hash-is-dead-long-live-html5-pushstate or using the hashbang/shebang system used by facebook or twitter: What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?

you could also mix the methods (e.g. use HTML5 pushState where available (by feature detection) and make regular requests on older browser).

Community
  • 1
  • 1
Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177
  • Thanks Fabrizio. I will look into this in detail later, when i'm at home. For the best user experience, which is important for me, it is important to use ajax, because one div-reloading looks much better than a whole page refresh. Anyway...how does facebook do it? When you click on your messages, the url changes but only the div in the center changes...is that html5? because the above example from gflsh is not working with my browser, but the facebook-effect is working! – Torben Jan 10 '12 at 09:44
  • Take a look at http://stackoverflow.com/questions/3009380/whats-the-shebang-hashbang-in-facebook-and-new-twitter-urls-for especially the raganwald's answer. – Fabrizio Calderan Jan 10 '12 at 09:50
0

suppose 4 sections are sec1, sec2, sec3, sec4. The links should be like this:

sec1

Clicking on sec1 will obviously take you to the address : root/inside/my_account

Istiaque Ahmed
  • 6,072
  • 24
  • 75
  • 141