51 lines
1.1 KiB
HTML
51 lines
1.1 KiB
HTML
<!-- start custom article top snippet -->
|
|
<style>
|
|
#myBtn {
|
|
display: none;
|
|
position: fixed;
|
|
bottom: 10px;
|
|
right: 10px;
|
|
z-index: 99;
|
|
font-size: 12px;
|
|
font-weight: bold;
|
|
border: none;
|
|
outline: none;
|
|
background-color: white;
|
|
color: black;
|
|
cursor: pointer;
|
|
padding: 5px;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
#myBtn:hover {
|
|
background-color: #555;
|
|
}
|
|
</style>
|
|
|
|
<button onclick="topFunction()" id="myBtn" title="Haut de page">⇧</button>
|
|
|
|
<script>
|
|
//Get the button
|
|
var mybutton = document.getElementById("myBtn");
|
|
|
|
// 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 > 20 || document.documentElement.scrollTop > 20) {
|
|
mybutton.style.display = "block";
|
|
} else {
|
|
mybutton.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;
|
|
}
|
|
</script>
|
|
|
|
|
|
<!-- end custom article top snippet -->
|