Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Window scrollBy() Method

Window scrollBy() Method

Window Object Reference Window Object


Definition and Usage

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

Note: For this method to work, the window scrollbar's visible attribute must be set to true!

Syntax

scrollBy(

xnum,ynum

)

Parameters Description
xnum Required. The number of pixels to scroll the document to the right.
ynum Required. The number of pixels to scroll the document down.

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 »


Window Object Reference Window Object