You can do this using jQuery.offset()
and jQuery.animate()
.
Check out the jsFiddle Demonstration.
function scrollToAnchor(aid){
var aTag = $("a[name='"+ aid +"']");
$('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
scrollToAnchor('id3');