Scroll to top button (back-to-top)
To add a button, you need to make the following changes in the "General settings":
![](https://storage.crisp.chat/users/upload/session/a42089083b18a800/chromeznv5ginadi_dyzur3.png)
![](https://storage.crisp.chat/users/upload/session/a42089083b18a800/chromeyzgrkswaph_1wa2fdg.png)
![](https://storage.crisp.chat/users/upload/session/a42089083b18a800/chromewyk4emzt8q_f9aomz.png)
1. In the "<head> custom HTML code" section, insert the following code:
<script>
function handleScroll() {
var scrollToTopBtn = document.getElementById("scrollToTopBtn");
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
scrollToTopBtn.style.display = "block";
} else {
scrollToTopBtn.style.display = "none";
}
}
function scrollToTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
window.onscroll = function() {
handleScroll();
};
</script>
![](https://storage.crisp.chat/users/upload/session/a42089083b18a800/chromeznv5ginadi_dyzur3.png)
2. In the "</body> custom HTML code" section, add the following code:
<button id="scrollToTopBtn" onclick="scrollToTop()">🔺</button>
<style>
#scrollToTopBtn {
display: none;
z-index: 999;
position: fixed;
bottom: 20px;
right: 48.5%;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 50px;
padding: 17px 15px;
cursor: pointer;
}
</style>
![](https://storage.crisp.chat/users/upload/session/a42089083b18a800/chromeyzgrkswaph_1wa2fdg.png)
3. Save the changes and open your page. The button will now appear as you scroll.
![](https://storage.crisp.chat/users/upload/session/a42089083b18a800/chromewyk4emzt8q_f9aomz.png)
Updated on: 22/08/2024
Thank you!