EmtaWiki
<script>
// Get the button
const backToTopButton = document.getElementById("BackToTop");
// Listen for scroll events
window.onscroll = function() {
toggleBackToTopButton();
};
function toggleBackToTopButton() {
// Show the button after scrolling down 100px from the top
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
backToTopButton.style.display = "block";
} else {
backToTopButton.style.display = "none";
}
}
// Smooth scroll to top on button click
backToTopButton.onclick = function() {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
</script>