I used the following on my site:
$(document).ready(function(){ $('a[href^="#"]').on('click',function (e) { e.preventDefault(); var target = this.hash, $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 1200, 'swing', function () { window.location.hash = target; }); });
});
You can change the scroll speed by changing the default "1200", it works quite well on most browsers.
after putting the code between the <head> </head> your page, you will need to create an internal link in the <body> :
<a href="#home">Go to Home</a>
Hope this helps!
Ps: Do not forget to call:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
Nahomy Atias Sep 06 '13 at 19:55 2013-09-06 19:55
source share