Window scrollTo()Method

Window 对象参考手册Window Object

Definition and Usage

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

Syntax

scrollTo(xpos,ypos)

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the scrollTo() method.


Example

Example

Scroll the content to coordinate position 100,500:

function scrollWindow(){
    window.scrollTo(100,500);
}

Try it Yourself »


Window 对象参考手册Window Object Other Extensions