MediaWiki
Foreground.js: Difference between revisions
From Grouse House Wiki
(Created page with "→Collapsible Headers on Desktop: var coll = document.getElementsByTagName('h2'); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.display === "block") { content.style.display = "none"; } else { content.style.display = "block"; } }); }") |
No edit summary |
||
| (68 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* | /* Scroll to top and sidebar logo */ | ||
var | var 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; | |||
} | } | ||
Latest revision as of 19:03, 1 February 2025
/* Scroll to top and sidebar logo */
var 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;
}
