MediaWiki
Foreground.js: Difference between revisions
From Grouse House Wiki
(Blanked the page) Tag: Blanking |
No edit summary |
||
Line 1: | Line 1: | ||
/* Scroll to top */ | |||
let scrollbutton = document.getElementById("scrollToTop"); | |||
window.onscroll = function() {scrollFunction()}; | |||
function scrollFunction() { | |||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { | |||
scrollbutton.style.display = "block"; | |||
} else { | |||
scrollbutton.style.display = "none"; | |||
} | |||
} | |||
function topFunction() { | |||
document.body.scrollTop = 0; | |||
document.documentElement.scrollTop = 0; | |||
} |
Revision as of 01:32, 1 April 2024
/* Scroll to top */ let scrollbutton = document.getElementById("scrollToTop"); window.onscroll = function() {scrollFunction()}; function scrollFunction() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { scrollbutton.style.display = "block"; } else { scrollbutton.style.display = "none"; } } function topFunction() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }