window.scrollBy()

JavaScript1.2+, JScript3.0+ Nav4+, IE4+ Syntax

							window.scrollBy(numHort, numVert)

Description

The scrollBy() method of the Window object scrolls the specified window by the number of pixels passed to the method. As shown in the syntax definition, the first numeric value passed to the method represents the number of vertical pixels by which you want to scroll the window, while the second numeric value represents the horizontal number of pixels.

If the numbers passed are positive, the window is scrolled in the positive direction. Negative numbers are scrolled in the negative direction.

Example

Listing 7.580 has four buttons. Each of these buttons scroll the windows contents in different directions when clicked.

Listing ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.