HTML DOM Window Scroll() Method Last Updated : 29 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The Window scroll() method scrolls the window to a particular place in the document. This method is different form scrollTo() method as it takes different parameters like scrolling behavior, etc using ScrolltoOptions Dictionary. Syntax: window.scroll(x-coord, y-coord) Or window.scroll(options) Parameters: x-coord: pixels along the horizontal axis of the document that you want to be scrolled to.y-coord: pixels along the vertical axis of the document that you want to be scrolled to. options: A ScrolltoOptions Dictionary. Example 1: In this example, we will scroll using ScrolltoOptions Dictionary. html <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>window scroll() method</title> </head> <body style="text-align:center;"> GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeks forGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeks GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksfor GeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeks forGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeks GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksfor GeeksGeeksforGeeks <h1 style="color:green;"> GeeksforGeeks </h1> <p id="a"> HTML | window scroll() method </p> <button onclick = "Geeks()"> Click Here to Scroll </button> <script> var a = document.getElementById("a"); function Geeks(){ window.scroll({ top: 100, left: 100, behavior: 'smooth' }); } </script> </body> </html> Output: Example 2: In this example, we will scroll using coords. html <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>window scroll() method</title> </head> <body style="text-align:center;"> GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeks forGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeks GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksfor GeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeks forGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeks GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksfor GeeksGeeksforGeeks <h1 style="color:green;"> GeeksforGeeks </h1> <p id="a"> HTML | window scroll() method </p> <button onclick = "Geeks()"> Click Here </button> <script> var a = document.getElementById("a"); function Geeks(){ window.scroll(500, 0); } </script> </body> </html> Output: Supported Browsers: Google ChromeEdgeFirefoxSafariOpera Comment More infoAdvertise with us Next Article HTML DOM Window scrollY Property T taran910 Follow Improve Article Tags : JavaScript HTML-DOM Similar Reads HTML Window scrollBy() method The window.scrollBy() method is used to scroll the document by a given number of pixels. Syntax: window.scrollBy( xcoordinate, ycoordinate ); or window.scrollBy(options); Parameters: This method accepts two parameters as mentioned above and described below: x-coordinate: It is the horizontal pixel v 2 min read HTML DOM Window moveTo() Method The moveTo() method is used in the window to moves the window from the left and top coordinates. Syntax: window.moveTo(x, y) Parameter: x: A positive or negative number that specifies the horizontal coordinate to be moved toy: A positive or negative number specifies the vertical coordinate to be mov 1 min read HTML DOM Window scrollX property The scrollX property of the Window interface returns the number of pixels that the document is currently scrolled horizontally in the current window. This value is subpixel precise in modern browsers, meaning that it isn't necessarily a whole number. This is a read-only property. Syntax: var Scrx = 1 min read HTML DOM Window scrollY Property The scrollY property of the Window interface returns the number of pixels that the document is currently scrolled vertically in the current window. This value is subpixel precise in modern browsers, meaning that it isn't necessarily a whole number. This is a read-only property. Syntax: var Scry = wi 1 min read HTML DOM Window scrollMaxX Property The Window scrollMaxX property returns the maximum number of pixels that the document can be scrolled horizontally in the current window. Window scrollMaxX is a read-only property. Syntax: var Scrx = window.scrollMaxX Return Value: This property returns the maximum number of pixels that the document 1 min read HTML DOM scrollWidth Property The DOM scrollWidth property is used to return the width of an element. This property includes padding and also content that is not visible on the screen due to overflow but does not include a border, scrollbar, or margin. It is a read-only property. Syntax: element.scrollWidth Return Value: It retu 1 min read Like