JavaScript: Auto Scroll to the top of a page

From The Travis van der Font Wiki
Jump to: navigation, search
Easiest way is to do this with jQuery:
$("html, body").animate({ scrollTop: 0 }, 'slow');
Want to scroll only half way to the top?
$("html, body").animate({ scrollTop: ($('body').height() / 2) }, 'slow');
Note: By changing 2 (the whole number) you can send the client to any part of the page divided by it's value in percentage.