window.scrollBy

書式

scrollBy(X移動量, Y移動量)
window.scrollBy(X移動量, Y移動量)

説明

ページを指定された量だけスクロールさせます。

サンプルコード [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<script type="text/javascript"><!--
function winScroll() {
window.scrollBy(20,30);
}
// --></script>
</head>
<body>
<form>
<input type="button" value="Scroll" onClick="winScroll()">
</form>
<div style="width:1000px;height:1000px;background-image:url(sky.jpg)"><img src="sky.jpg"></div>
</body>
</html>