I have one page design with scrolling eased by jquery using this code:
function ScrollMe(id){
var offset = $("#"+id).offset().top-50;
$('html,body').animate({scrollTop: offset},'slow');
};
And this html:
<a onclick="ScrollMe('about')" href="javascript:void(0)">About</a>
works fine, but what I need is to change href to “#about” so the url would be updated when is clicked on link. I just dont know how to keep easing in that case.
Thanks
EDIT
so for me works good enough this one:
<a href="#contact" onclick="return scrollMe('contact');">
Why not simply set
idof anchor correctly sethref? Like this, for example:This correctly sets browser’s location, so it can be copied and transfered. But if you want animation to be played when your page is opened from another page, not this, you should call smth like
scrollMe(location.hash)after page was loaded.NOTE:
location.hashmight note work on some browsers.