The Window.scrollBy() method scrolls the document in the window by the given amount.


window.scrollBy(x-coord, y-coord);


  • 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.

- or -


To scroll down one page:

window.scrollBy(0, window.innerHeight);

To scroll up:

window.scrollBy(0, -window.innerHeight);

Using options:

  top: 100,
  left: 100,
  behavior: 'smooth'


window.scrollBy() scrolls by a particular amount, whereas window.scroll() scrolls to an absolute position in the document. See also window.scrollByLines() and window.scrollByPages().


Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'window.scrollBy()' in that specification.
Working Draft Initial definition.

Browser Compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
scrollByChrome Full support 1Edge Full support 79
Full support 79
No support 12 — 79
Notes Only scrollBy(x-coord, y-coord) is supported.
Firefox Full support 1IE Partial support 11
Partial support 11
Notes Only scrollBy(x-coord, y-coord) is supported.
Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0
ScrollToOptions parameterChrome Full support 45Edge Full support 79Firefox Full support YesIE No support NoOpera Full support 32Safari No support NoWebView Android Full support 45Chrome Android Full support 45Firefox Android Full support YesOpera Android Full support 32Safari iOS No support NoSamsung Internet Android Full support 5.0


Full support  
Full support
Partial support  
Partial support
No support  
No support
See implementation notes.
See implementation notes.