<!DOCTYPE html> <html> <head> <style> body { width: 5000px; } button { position: fixed; } </style> </head> <body> <h1>Window 对象</h1> <h2>scrollBy() 方法</h2> <p>单击其中一个按钮(多次)可滚动文档。</p> <p>请看滚动条,能看到效果。</p> <button onclick="scrollWin(100, 0)">向右滚动</button><br><br> <button onclick="scrollWin(-100, 0)">向左滚动</button><br><br> <script> function scrollWin(x, y) { window.scrollBy(x, y); } </script> </body> </html>