files/en-us/web/api/window/scrollby/index.md
{{APIRef}}
The Window.scrollBy() method scrolls the document in the
window by the given amount.
scrollBy(xCoord, yCoord)
scrollBy(options)
xCoord
yCoord
options
top
left
behavior
smooth), happen instantly in a single jump (instant), or let the browser choose (auto, default).None ({{jsxref("undefined")}}).
To scroll down one page:
window.scrollBy(0, window.innerHeight);
To scroll up:
window.scrollBy(0, -window.innerHeight);
Using options:
window.scrollBy({
top: 100,
left: 100,
behavior: "smooth",
});
window.scrollBy() scrolls by a particular amount, whereas
{{domxref("window.scroll()")}} scrolls to an absolute position in the document. See also
{{domxref("window.scrollByLines()")}} and {{domxref("window.scrollByPages()")}}.
{{Specifications}}
{{Compat}}