Scroll To Top of Page Button

Reviewing other posts such as Scroll to error or top of page on submit and others, I have tried adding this onclick line to my button. The button is located where I want and looks good but it doesn’t scroll to the top of the page when clicked.

Anyone have a quick solution? I bet it is easy but I can’t find any direct match to my need in the the Community posts.

I have tried this from W3schools.com as well:

function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}

Button CSS

.top-button-float {
/*display: none; Hidden by default /
position: fixed; /
Fixed/sticky position/
bottom: 100px; /
Place the button at the bottom of the page/
right: 20px; /
Place the button 30px from the right/
border: 1px solid
#ccc; /Border/
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /
Shadow effect/
transition: transform 0.3s ease; /
Smooth transition/
padding: 10px;
border-radius: 5px;
z-index: 1000; /
Higher value to stay above other elements */
background-color: black !important;
}

Hi @shedev,

Have you tried scrollTo()?

window.scrollTo(0, 0);

This should work in all modern browsers. Note that it won't work for a Public form preview since previews are rendered via iframes; this code is only for the form page.

@IliaLazarevskii - I have tried this and tried again just now with no success.

GENERAL > CLICK:

Hi @shedev,

Could you share more about which version of the app you use and how the form is opened?

@IliaLazarevskii - Sure! I am using Plumsail Forms 4.0.3 for SharePoint Online. I have many buttons on the page that are working as expected but the “Jump to Top” does not. Thank you for asking!