Window:scrollByLines() 方法
非标准: 该特性是非标准的,请尽量不要在生产环境中使用它!
Window.scrollByLines()
方法按指定的行数滚动文档。
语法
js
scrollByLines(lines)
参数
lines
-
滚动文档的行数,可以是正整数或负整数。
返回值
无(undefined
)。
示例
html
<!-- 将文档向上滚动 5 行 -->
<button id="scroll-up" onclick="scrollByLines(-5);">向上 5 行</button>
<!-- 将文档向下滚动 5 行 -->
<button id="scroll-down" onclick="scrollByLines(5);">向下 5 行</button>
规范
这不属于任何规范。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
scrollByLines |
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.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.