Auto back to top link

DescriptionJavascript snippet by - 02/27/11

This html javascript combo will show a back to top link only when the browser content is greater than a certain height. Just change the 1000 value which is the minimum height required in pixels to show the back to top link.

This allows you to put a back to top link in your template files and it will only show up on pages that are lengthy, automatically. We all like that.
<p id="to-top-link" style="text-align:center; display:none;"><a href="#">Back to Top</a></p>
<script type="text/javascript">if(document.body.clientHeight > 1000) document.getElementById('to-top-link').style.display = 'block';</script>
  • Share
Authored by: Adam J Nowak
http://hyperspatial.com

Comments and Feedback