/

HTML / CSS / JavaScript Tutorial

JavaScript Window method: scrollTo()

[this page | pdf | back links]

The scrollTo() method (when applied to Window objects in the JavaScript BOM) scrolls the document to specified coordinates.

 

It has the following syntax with the following parameters. It does not return a value.

 

window.scrollTo(x, y)

 

Parameter

Required / Optional

Description

x

Required

Number of pixels to scroll to, along horizontal axis

y

Required

Number of pixels to scroll to, along vertical axis

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile