Search w3schools.com:

SHARE THIS PAGE

Window scrollTo() Method

Window Object Reference Window Object

Definition and Usage

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

Syntax

scrollTo(xpos,ypos)

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

Internet Explorer Firefox Opera Google Chrome Safari

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 Reference Window Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]