运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 Spaces
<!DOCTYPE html> <html> <head> <style> div { background-color: lightblue; height: 2000px; width: 2000px; } </style> </head> <body> <h1>The Window Object</h1> <h2>The pageXOffset and pageYOffset Properties</h2> <p>Click the button to scroll the document window 100px horizontally and vertically.</p> <button onclick="myFunction()" style="position:fixed;">Click me to scroll</button><br><br> <div></div> <script> function myFunction() { window.scrollBy(100, 100); alert("pageXOffset: " + window.pageXOffset + ", pageYOffset: " + window.pageYOffset); } </script> </body> </html>