where xAxis specifies the number of pixels window is to be scrolled along X-axis and yAxis specifies the number of pixels window is to be scrolled along Y-axis and both of these arguments are required.
Description of code:
To illustrate the use of scrollBy() method, we have created a simple example which will scroll window by the 100, 100 pixels position on the X-axis and Y-axis both. Here in HTML page we have created a button "Scroll" which calls the function scrollWindow() when clicked. In this function we have called the scrollBy() method with the window object.
Here is the full HTML code for scrollBymethod.html as follows :
Click on the "Scroll" button to scroll window upward with the 100 pixels on X-axis and 100 pixels on Y-axis.
You can see that it has scrolled the window with the X-axis and Y-axis positions provided into scrollBy() method.
You can also download the full source code by the following link.