Scroll the document to position "300" horizontally and "500" vertically:
window.scrollTo(300, 500);
Click the button to scroll the document window 300 pixels horizontally and 500 pixels vertically.
<!DOCTYPE html> <html> <head> <style> body {// w ww .j a va 2 s .com width: 5000px; } </style> </head> <body> <button onclick="scrollWin()">Click me to scroll</button> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <p>SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL SCROLL</p> <br> <br> <br> <br> <br> <br> <br> <br> <script> function scrollWin() { window.scrollTo(300, 500); } </script> </body> </html>