javascript – Scroll the page not by 100px but by 100vh



Question: How to make a button that will scroll the page not by a certain number of pixels, but by 100vh, which is equal to 100% of the window's height.

If a block has a height of 100vh, then it will be stretched to the full height of the block, whatever its height.


You need to hang an event handler on the button (for example). So that when the button is pressed, the screen scrolls the page to the height of the page, you can write a function where it will be:

window.scrollBy(0, window.innerHeight);

The button itself, something like this:

<button onclick = 'window.scrollBy(0, window.innerHeight)'>window.scrollBy(0, window.innerHeight)</button>
Scroll to Top