Javascript examples for DOM:Element scrollTop
Element scrollTop Property - Scroll the contents of <body> by 30 pixels horizontally and 10 pixels vertically:
<!DOCTYPE html> <html> <head> <style> body {//w w w .java 2s. c o m height: 2000px; width: 2000px; } button { position: fixed; } </style> </head> <body> <button onclick="myFunction()">Scroll contents of body</button><br><br> <script> function myFunction() { var body = document.body; // For Chrome, Safari and Opera var html = document.documentElement; // Firefox and IE body.scrollLeft += 30; body.scrollTop += 10; html.scrollLeft += 30; html.scrollTop += 10; } </script> </body> </html>