MediaWiki:Jump-button.js

Aus LohnAs Wiki Test
Version vom 24. Juli 2018, 09:58 Uhr von Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „// JavaScript source code var jumpPos = 0 // When the user scrolls down 20px from the top of the document, show the button window.onscroll = function() {scr…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche
// JavaScript source code

var jumpPos = 0 

// 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 > 400 || document.documentElement.scrollTop > 400) {
        document.getElementById("jump-button").style.display = "block";
    } else {
        document.getElementById("jump-button").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;
}