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-coord
is the horizontal pixel value that you want to scroll by.y-coord
is the vertical pixel value that you want to scroll by.options
is aScrollToOptions
dictionary.
Examples:
To scroll down one page:
window.scrollBy(0, window.innerHeight);
To scroll up one page:
window.scrollBy(0, -window.innerHeight);
Reference: Window.scrollBy()