views:

17

answers:

1

Hello there ok i may be wrong about this and if i am then i am sorry. But is it possible to change the screen with ajax by looking at whats after the "#" in the link. because when im on facebook i know that it is all an iframe yet when the screen changes so does the text after the "#". Is that what is causing the change or is that a result of the change. Because i have JavaScript on my site and when you click a function it adds a "#" to the link but never any text.

Thank you so much.

+1  A: 

The part of the URL after the # is called the "hash tag" and you can use JavaScript to change it like this:

document.location = "#abc"

You can also set the hash tag using an anchor like this:

<a href="#abc">Click me to put #abc on the end of the url</a>

To get the hash tag you can use this:

hash_tag = window.location.hash

Facebook is not displayed inside an iFrame but all of the content is generated using JavaScript, and they set the hash tag deliberately so when you reload the page, they can look at the hash tag and give you the right content.

BudgieInWA
okay so they change the content and then additionally change the hash so if you refresh? So then how can you read a hash tag so you know what to display? BTW thanks
Matthew Carter
Following on from the code in the answer to get the hash tag: `if (hash_tag=="abc"){alert("Now I will load the abc page");}`. Run that code when the page loads.
BudgieInWA