HTML DOM Window Scroll() Method Read Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue 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. <!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. <!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 Chrome Edge Firefox Safari Opera Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now! Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore. Last Updated : 29 Jul, 2020 Like Article Save Article Previous HTML DOM deleteFromDocument() method Next HTML DOM queueMicrotask() Method Share your thoughts in the comments Add Your Comment Please Login to comment...