test code:
jQuery code:
jQuery(function($){ $('a[href=#top]').click(function(){ $('html, body').animate({scrollTop:0}, 1000); return false; }); });
html code:
<a name="top"></a> ...page content... <a href="#top">back to top</a>
Code works in all major browsers. Works even without javascript enabled.