代码示例:(标识:jsck_win_scrollby_3)
<!DOCTYPE html>
<html>
<head>
<style>
body {
  height: 7500px;
}
button {
  position: fixed;
}
</style>
</head>
<body>

<h1>Window 对象</h1>

<h2>scrollBy() 方法</h2>

<p>单击其中一个按钮(多次)可滚动文档。</p>

<p>Look at the scrollbar to see the effect.</p>

<button onclick="scrollWin(0, 50)">向下滚动</button><br><br>
<button onclick="scrollWin(0, -50)">向上滚动</button><br><br>

<script>
function scrollWin(x, y) {
  window.scrollBy(x, y);
}
</script>

</body>
</html>
运行结果: