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

Window scrollTo() Method

Window scrollTo() Method

Window Object Reference Window Object


Definition and Usage

The scrollTo() method scrolls the content to the specified coordinates.

Syntax

scrollTo(

xpos,ypos

)

Parameters Description
xpos Required. The x-coordinate of the document to be displayed at the upper-left corner of the window's viewport.
ypos Required. The y-coordinate of the document to be displayed at the upper-left corner of the window's viewport.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the scrollTo() method.


Example

Example

Scroll the content to the coordinates 100,500:

function scrollWindow(){

    window.scrollTo(100,500);

}

Try it »


Window Object Reference Window Object