Window scrollBy()Method

Window 对象参考手册Window Object


Definition and Usage

The scrollBy() method scrolls the content by the specified number of pixels.

Note:For this method to work, the visibility property of the window scrollbar must be set to true!

Syntax

scrollBy(xnum,ynum)

Parameter Description
xnum Required. The number of pixels to scroll the document to the right.
ynum Required. The number of pixels to scroll the document downward.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the scrollBy() method


Example

Example

Scroll the content by 100 pixels:

function scrollWindow(){ window.scrollBy(100,100); }

Try it Yourself »


Window 对象参考手册Window Object

Other Extensions