Back to top - New feature


Item has a rating of 5 (Liked by Chris GrahamLiked by Joey)
#2890 (In Topic #521)
Standard member
Paul Flavel is in the usergroup ‘Honoured member’
Here is a quick tutorial on how to create a conditional back to top button as you scroll down the page.

Open your GLOBAL_HTML_WRAP.tpl

Just before </body> add the following.

<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
    if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
        document.getElementById("myBtn").style.display = "block";
    } else {
        document.getElementById("myBtn").style.display = "none";

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
    document.body.scrollTop = 0;
    document.documentElement.scrollTop = 0;

Then in your global.css add the following down the bottom:


#myBtn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 30px;
  z-index: 99;
  border: none;
  outline: none;
  background-color: red;
  color: white;
  cursor: pointer;
  padding: 15px;
  border-radius: 10px;

#myBtn:hover {
  background-color: #555;

Customise the css to suite your site

Online now: No Back to the top
1 guest and 0 members have just viewed this.


Users online:

Philip, Salman, Manu, deepu_ms, Paul D, MVLipwig, amit.nigam, Vaiva, John Connor

Forum statistics:
  • 1,292 topics, 5,826 posts, 7,052 members
  • Our newest member is dhanandip
Back to Top