views:

451

answers:

1

I'm building a series of basic accordions for a project.

We want them to have static, linkable pages. So we've created invidividual pages for each of the open states as well.

For example,

/whoweare is the main slider.

But we have a sub slider located at /whoweare/whatwedo

What I'm looking to have done is, when a user clicks a header on /whoweare, the slider opens, and the url bar updates to /whoweare/whatwedo, but there is no actual redirect. The url location should simply change, nothing more.

I've tried using

window.location.replace($(this).attr('href'));
return false;

But that doesn't seem to have accomplished what I wanted, it still reloads onto a new page.

Any other suggestions?

+3  A: 

You cannot change the URL without redirecting - it'd be a phishing nightmare (changing URL to that of a bank while staying on the phishing site, for example).

You can only manipulate the document hash - i.e. http://domain.com/#identifier - which is how Google, Facebook, etc. provide AJAX sites with browser history support.

Exact duplicate of #352343 Changing browser’s address bar without refreshing.

ceejayoz
Thanks for this,I'll just have to work around it.
Paul