Window scrollTo() Method
Window Object
Definition and Usage
The scrollTo() method scrolls the content to the specified coordinates.
Syntax
| Parameter |
Description |
| xpos |
Required. The coordinate to scroll to, along the x-axis |
| ypos |
Required. The coordinate to scroll to, along the y-axis |
Browser Support

The scrollTo() method is supported in all major browsers.
Example
Example
Scroll the content to position 100,500:
<html>
<head>
<script>
function scrollWindow()
{
window.scrollTo(100,500)
}
</script>
</head>
<body>
<input type="button" onclick="scrollWindow()" value="Scroll">
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p>
</body>
</html>
Try it yourself »
Window Object
Thank You For Helping Us!
Your message has been sent to W3Schools.
Close [X]