jQuery ScrollTop: go to position


<a href="#" class="go-to" data-go-to="#page">Click here to go</a>

jQuery('.go-to').click(function(ev){
    ev.preventDefault();
    var scroll_top = $($(this).attr('data-go-to')).offset().top;
    var speed = parseInt(scroll_top / 2);
    customScrollTo(scroll_top, speed);
});

function customScrollTo(topValue, time){
    jQuery("html, body").animate({
        scrollTop: topValue
    }, time);
}

Goto from  different pages

jQuery('#top_search').click(function(ev){
    if (window.location.href==home_url) {
        ev.preventDefault();
        var scroll_top = jQuery('#home_quick_search').offset().top;
        customScrollTo(scroll_top, 2000);
    }
});

if (window.location.hash){
    setTimeout(function(){
        $('html, body').scrollTop(0).show();
        var scroll_top = jQuery('#home_quick_search').offset().top;
        customScrollTo(scroll_top, 2000);
    }, 0);
}