Window.scrollBy()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.
Window.scrollBy()
메서드는 창에 있는 문서를 지정된 양만큼 스크롤합니다.
구문
js
scrollBy(x-coord, y-coord)
scrollBy(options)
매개변수
반환 값
없음 (undefined
).
예제
한 페이지 아래로 스크롤하려면.
js
window.scrollBy(0, window.innerHeight);
위로 스크롤하려면.
js
window.scrollBy(0, -window.innerHeight);
options
사용.
js
window.scrollBy({
top: 100,
left: 100,
behavior: "smooth",
});
참고
window.scroll()
가 문서의 절대 위치로 스크롤하는데 반해, window.scrollBy()
는 특정 양만큼 스크롤합니다.
window.scrollByLines()
와 window.scrollByPages()
를 참조하십시오.
명세서
Specification |
---|
CSSOM View Module # dom-window-scrollby |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
scrollBy | ||||||||||||
options.behavior parameter | ||||||||||||
options.left parameter | ||||||||||||
options.top parameter |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.