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

Window scrollTo() Method

Window Object Reference Window Object

Example

Scroll the document to the horizontal position "500":

window.scrollTo(500, 0);

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

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

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


Browser Support

Method
scrollTo() Yes Yes Yes Yes Yes


Syntax

window.scrollTo(xpos,ypos)

Parameter Values

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

Technical Details

Return Value: No return value


Examples

More Examples

Example

Scroll the document to position "300" horizontally and "500" vertically:

window.scrollTo(300, 500);

Try it yourself »


Related Pages

Window Object: scrollBy() Method


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 HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook