이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 참여해서 번역을 마치도록 도와 주세요!
English (US)의 문서도 읽어보세요.

Summary

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.

- or -

  • options is an object with three possible properties:
    • top, which is the same as the y-coord
    • left, which is the same as the x-coord
    • behavior, which is a string containing one of smooth, instant, or auto; default is auto

 

Example

 

// scroll down one page
window.scrollBy(0, window.innerHeight);

To scroll up:

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

Notes

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

Specification

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
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge ? Firefox Full support YesIE ? Opera ? Safari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support YesOpera Android ? Safari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

문서 태그 및 공헌자

최종 변경자: zargold,