Scroll the document to the horizontal position "500":
More "Try it Yourself" examples below.
The scrollTo() method scrolls the document to the specified coordinates.
Tip: Use the scrollBy() method to scroll a specified distance multiple times.
Method | |||||
---|---|---|---|---|---|
scrollTo() | Yes | Yes | Yes | Yes | Yes |
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 |
Return Value: | No return value |
---|
Scroll the document to position "300" horizontally and "500" vertically:
Window Object: scrollBy() Method