This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

scroll

Summary

Causes the window to scroll to the specified x- and y-offset at the upper-left corner of the window.

Method of dom/Windowdom/Window

Syntax

 window.scroll(/* see parameter list */);

Parameters

x

Data-type
Number

Integer that specifies the horizontal scroll offset, in pixels.

y

Data-type
Number

Integer that specifies the vertical scroll offset, in pixels.

Return Value

No return value

Examples

<!-- put the 100th vertical pixel at the top of the window -->

<button onClick="scroll(0, 100);">click to scroll down 100 pixels</button>

Notes

Remarks

This method is provided for backward compatibility only. The recommended way to scroll a window is to use the scrollTo method.

Attributions

  • Mozilla Developer Network cc-by-sa-small-wpd.svg: [scroll Article]

  • Microsoft Developer Network: [scroll Method Article]