DJCMBear
12-17-2010, 03:30 PM
Hey I am in need of some help with a hash removal detection code, currently I have everything I need to do what I want but when I click the back button and the hash is removed from the url I need to have a script run to then change the page content.
My design looked sort of like this.
function detect() {
var url = window.location;
if(url.indexOf('#') === -1) {
// run the code
}
}
But that ran the code every time there wasn't any hash in the url so if a user went to lets say /index.php the page content would keep being re-generated as there isn't any hash, so my question is how can I make it so it only runs only if there has been a hash in the url and then has been removed so like if you went to /index.php and clicked a link that took you to /index.php#tags and then the page content was changed with ajax, then the user clicked the browsers back button to go back to /index.php, the page would still have the tags content on it so that's when I need the function to run to change it back again.
If anyone can help with my problem please reply.
Thank you
- DJCMBear
My design looked sort of like this.
function detect() {
var url = window.location;
if(url.indexOf('#') === -1) {
// run the code
}
}
But that ran the code every time there wasn't any hash in the url so if a user went to lets say /index.php the page content would keep being re-generated as there isn't any hash, so my question is how can I make it so it only runs only if there has been a hash in the url and then has been removed so like if you went to /index.php and clicked a link that took you to /index.php#tags and then the page content was changed with ajax, then the user clicked the browsers back button to go back to /index.php, the page would still have the tags content on it so that's when I need the function to run to change it back again.
If anyone can help with my problem please reply.
Thank you
- DJCMBear