Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2014
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Hash Bookmaking & Linking on Single Page Website

    Hey guys, this is my first post here after being randomly banned on another site (which shall remain nameless).
    Anyways I'm looking for help, my website uses a JQuery content changing system and I want to add the ability to bookmark and link specific pages. I have tried doing this with the
    Code:
    window.location.hash
    method however it doesn't seem to be working correctly. Can anyone help me resolve this?
    Below is the hash portion of the JavaScript and heres a JSFiddle of the whole site.
    Code:
    var hash = window.location.hash;
    console.log(hash);
    if (hash == "#home"){
    	hidecontent();
    	$("#home").show();
    	$("#copyright").trigger("click");
    }
    if (hash == "#about"){
    	hidecontent();
    	$("#aboutme").show();
    	$("#copyright").trigger("click");
    }
    if (hash == "#blog"){
    	hidecontent();
    	$("#blog").show();
    	$("#copyright").trigger("click");
    }
    if (hash == "#services"){
    	hidecontent();
    	$("#services").show();
    	$("#copyright").trigger("click");
    }
    if (hash == "#creations"){
    	hidecontent();
    	$("#creations").show();
    	$("#copyright").trigger("click");
    }
    if (hash == "#contact"){
    	hidecontent();
    	$("#creations").show();
    	$("#copyright").trigger("click");
    }
    else{
    	hidecontent();
    	$("#home").show();
    	$("#copyright").trigger("click");
    }
    Thank you

  • #2
    New Coder
    Join Date
    Jul 2014
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I don't know how this issue got resolved but just leaving it for a few days has made it work. I guess this code is right then...Strange!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •