0

So all of my content is on one page, it's divided into tabs using jQuery UI Tabs. So when a user changes tab, there's no page reload; it's all done in Javascript/Ajax.

How would I change the current url, this bit:
Example header

To whatever it currently is plus /example at the end?

So change www.mywebsite.com to www.mywebsite.com/example.

I want to create a re-usable method that I can just pass in something like changeHeaderTo('example') rather than specifying the domain part. As this needs to be done for several combinations of /x, /x/y, /x/z, etc.

Is this even possible/how would this be done?

user3420034
  • 1,275
  • 2
  • 20
  • 43
  • Check out http://pjax.herokuapp.com/ or https://github.com/browserstate/history.js. Both of those help handle older browser compatilibity and whatnot. – Ding Jan 13 '15 at 20:31
  • 1
    I just tested this and it seems to do what you're asking: http://stackoverflow.com/questions/352343/is-there-a-way-to-change-the-browsers-address-bar-without-refreshing-the-page – Michael Hommé Jan 13 '15 at 20:33
  • Also `window.history.pushState("object or string", "Title", "/example");` would work if you're not worried about compatibility. – Ding Jan 13 '15 at 20:34
  • You could do this easily with a #. window.location.hash = #example – Red2678 Jan 13 '15 at 21:02

0 Answers0