x
 
<!DOCTYPE html>
<html>
<head>
<style>
div {
  background-color: lightblue;
  height: 2000px;  width: 2000px;
}
</style>
</head>
<body>
<h1>Window 对象</h1>
<h2>scrollX 和 scrollY 属性</h2>
<p>单击该按钮可将文档窗口水平和垂直滚动 100px。</p>
<button onclick="myFunction()" style="position:fixed;">点我滚动</button><br><br>
<div></div>
<script>
function myFunction() {
  window.scrollBy(100, 100);
  alert("pageXOffset: " + window.scrollX + ", scrollY: " + window.scrollY);
}
</script>
</body>
</html>