Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

Summary

Scrolls the document in the window by the given amount.

Syntax

window.scrollBy(X, Y);

Parameters

  • X is the offset in pixels to scroll horizontally.
  • Y is the offset in pixels to scroll vertically.

Positive co-ordinates will scroll to the right and down the page. Negative values will scroll to the left and up the page.

Example

// scroll one page 
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.

文档标签和贡献者

 最后编辑者: cvrebert,