You can use jQuerysjQuery's .animate(), .offset() and scrollTop
. Like
$(document.body).animate({
'scrollTop': $('#anchorName2').offset().top
}, 2000);
exampleExample link: http://jsbin.com/unasi3/edit
If you don't want to animate, use .scrollTop() like:
$(document.body).scrollTop($('#anchorName2').offset().top);
or javascriptsOr JavaScript's native location.hash
like:
location.hash = '#' + anchorid;