MediaWiki
Foreground.js: Difference between revisions
From Grouse House Wiki
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
/* Scroll to top */ | /* Scroll to top and sidebar logo */ | ||
var scrollbutton = document.getElementById("scrollToTop"); | var scrollbutton = document.getElementById("scrollToTop"); | ||
var sidebarlogo = document.getElementById("sidebarlogo"); | |||
window.onscroll = function() {scrollFunction()}; | window.onscroll = function() {scrollFunction()}; | ||
Line 8: | Line 9: | ||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { | if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { | ||
scrollbutton.style.display = "block"; | scrollbutton.style.display = "block"; | ||
sidebarlogo.style.display = "block"; | |||
} else { | } else { | ||
scrollbutton.style.display = "none"; | scrollbutton.style.display = "none"; | ||
sidebarlogo.style.display = "none"; | |||
} | } | ||
} | } |
Latest revision as of 01:43, 1 April 2024
/* Scroll to top and sidebar logo */ var scrollbutton = document.getElementById("scrollToTop"); var sidebarlogo = document.getElementById("sidebarlogo"); window.onscroll = function() {scrollFunction()}; function scrollFunction() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { scrollbutton.style.display = "block"; sidebarlogo.style.display = "block"; } else { scrollbutton.style.display = "none"; sidebarlogo.style.display = "none"; } } function topFunction() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }