Window.scrollByLines()

非標準: この機能は標準ではなく、標準化の予定もありません。公開されているウェブサイトには使用しないでください。ユーザーによっては使用できないことがあります。実装ごとに大きな差があることもあり、将来は振る舞いが変わるかもしれません。

Window.scrollByLines() メソッドは、指定された行数だけ文書をスクロールさせます。

構文

js
window.scrollByLines(lines);

引数

  • lines は文書をスクロールする行数です。これは正または負の整数を指定することができます。

html
<!-- 文書を 5 行だけ上方向にスクロールする -->
<button id="scroll-up" onclick="scrollByLines(-5);">Up 5 lines</button>

<!-- 文書を 5 行だけ下方向にスクロールする -->
<button id="scroll-down" onclick="scrollByLines(5);">Down 5 lines</button>

仕様書

どの仕様書にもありません。

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
scrollByLines
Non-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.

関連情報