4

Possible Duplicate:
How to scroll HTML page to given anchor using jQuery or Javascript?

I'm using Sammy.js, and it handles all the client-side URL navigation. I want to navigate to /page#fragment, but the page wont actually go to #fragment. How can I make it do that, either automatically, or by writing code to go to the fragment?

2
  • not a duplicate - this question is specifically about sammy.js
    – Andy
    Commented Feb 19, 2014 at 15:45
  • definitely not a duplicate.
    – bkrall
    Commented Oct 2, 2015 at 20:46

1 Answer 1

2

Sammy doesnt automatically trigger the route, so in your handler you need to add:

hash = window.location.hash
if(hash != '') { 
    window.location.hash = hash;
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.