About Lesson
The window.scrollBy() method is used to scroll the document by a given number of pixels.
Syntax:
window.scrollBy( xcoordinate, ycoordinate );
Parameters: This method accepts two parameters as mentioned above and described below:
- x-coordinate: It is the horizontal pixel value that indicates how much you want to scroll the document (in terms of px).
- y-coordinate: It is the vertical pixel value that indicates how much you want to scroll the document (in terms of px).
The Window scrollTo() method is used to scroll to a particular set of coordinates in the document.
Syntax:
window.scrollTo(x-coord, y-coord)
Parameters: The scrollTo() method accepts two parameters as described below:
- x-coord: It is the pixel along the horizontal axis of the document that is displayed in the upper left. It is the required field.
- y-coord: It is the pixel along the vertical axis of the document that is displayed in the upper left. It is the required field.
Exercise Files
No Attachment Found
Join the conversation