I have a function that changes the hash in the url and inserts/removes a div from my main page. I did this was so that I can have a page that you can maneuver through without a reload, but at the same time i wanted people to be able to bookmark a certain section and go to it later without having to go through the page again.
When i try to call my hash()
function, which closes all divs and opens up the specific div depending on the hash, it doesn't work. I probably dont have the right thing in the if
statements, because when I put an alert()
in the hash()
function, it pops up like its supposed to.
function hash(){
if ( window.location.hash == "dcontact" ) {
removedivs();
InsertContent('dcontact');
}
if ( window.location.hash == "dhome" ) {
removedivs();
InsertContent('dhome');
}
}
hash();
I'm aware that there are probably better ways of doing everything i mentioned, but this is the only website I'm going to be making, and I couldn't care less how messy the script is in the end, as long as it works.