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?
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.
update: HTML5 now allows pushState
, but only within the same domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With