Javascript examples for Browser Object Model:Window scrollTo
Window scrollTo() Method - Scroll the document to position "300" horizontally and "500" vertically:
<!DOCTYPE html> <html> <head> <style> body {//from ww w. ja v a 2 s . c om 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>