Scroll to Top link
Description: This is a no fuss script for automatically scrolling the page back to the very top when invoked. For long pages, having a scroll to top link makes good usability sense, and with this script, it's dead simple to add one to your pages. The standonly script doesn't rely on any JS script library (such as jQuery), and as such, is as non convoluted and easy to integrate as can be!
Demo: Click on the [ Top ] link at the lower right corner of this page (or any page throughout DD).
Simply insert the following script in the HEAD section of your page:
If you wish to add the above code inside a .js file instead,
simply remove the surrounding
<script></script> tags from it
Then, simply invoke the function
to scroll a page to the very top. This can done most typically via a link, such
The default animation time to scroll to the top is 500 milliseconds; you can change this by passing an explicit parameter into the function when calling it, such as:
And that's all there is to it!