It is done - we hope you like our new style.
Please remember to make use of the Manual of Style and Code of Conduct during your stay on the wiki.

 Actions

MediaWiki

Difference between revisions of "ScrollTop.js"

From Dragon Mania Legends Wiki

m
m (Test js/css scroll on Monobook)
 
Line 1: Line 1:
 +
/* Insert Top Button after Body Content */
 +
 +
$(function() {
 +
  $('<button onclick="topFunction()" id="topBtn" title="Go to top"></button>').insertAfter('div#mw-content-text');
 +
});
 +
 
// When users scroll down 100px, show the Top button
 
// When users scroll down 100px, show the Top button
 
window.onscroll = function() {scrollFunction()};
 
window.onscroll = function() {scrollFunction()};

Latest revision as of 03:48, 14 July 2019

/* Insert Top Button after Body Content */

$(function() {
  $('<button onclick="topFunction()" id="topBtn" title="Go to top"></button>').insertAfter('div#mw-content-text');
});

// When users scroll down 100px, show the Top button
window.onscroll = function() {scrollFunction()};

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

// When users click on Top button, scroll up
function topFunction() {
  document.body.scrollTop = 0;
  document.documentElement.scrollTop = 0;
}