0

I don't know how to describe this, but I have a website that dynamically loads content using ajax. Therefore, the page is never reloaded and the URL stays the same. I would like the page to never refresh, but the URL to change, so people can copy and paste the URL and share it. When someone goes to the URL it will auto update the ajax to the content that should be on screen.

Now that was an awful description.

Here's an example:

http://www.phish.com

http://phish.com/#/music/

2 Answers 2

2

If you change the url completely even with javascript then in that case the whole page reloads.

You can add parameter after # in url which can act as an identifier for different page.

You can add it as follows -

window.location.href = window.location.href+'#identifier';

as you told that you are loading the page with ajax so you can obtain the identifier from url as follows -

var identifier = window.location.hash;

And so depending on the value of identifier you can load different contents.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 , changing after the hash is the accepted way of dealing with this problem I think. Gmail and other ajax-heavy Google sites do this a lot.
0

You might want to have a look at sammy.js.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.