The Window.scrollBy() method scrolls the document in the window by the given amount.
The Window.scrollBy() method scrolls the document in the window by the given amount.
Syntax:
window.scrollBy(x-coord, y-coord)window.scrollBy(options)
Parameters:
x-coordis the horizontal pixel value that you want to scroll by.y-coordis the vertical pixel value that you want to scroll by.optionsis aScrollToOptionsdictionary.
Examples:
To scroll down one page:
window.scrollBy(0, window.innerHeight);To scroll up one page:
window.scrollBy(0, -window.innerHeight);
Reference: Window.scrollBy()