X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Window scrollTo() Method

Window Object Reference Window Object

Example

Scroll the content to the horizontal position 500:

window.scrollTo(500,0);

Try it yourself »


Definition and Usage

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

Tip: Use the scrollBy() method to scroll a specified distance multiple times.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The scrollTo() method is supported in all major browsers.


Syntax

window.scrollTo(xpos,ypos)

Parameter Values

Parameter Description
xpos Required. The coordinate to scroll to, along the x-axis (horizontal)
ypos Required. The coordinate to scroll to, along the y-axis (vertical)

Return Value

No return value.


More Examples

Example

Scroll the content to position 300,500:

window.scrollTo(300,500);

Try it yourself »


Window Object Reference Window Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook