Window: scrollByPages() 方法

非标准:此特性未标准化。我们不建议在生产环境中使用非标准特性,因为它们浏览器支持有限,并且可能会更改或被移除。但是,在没有标准选项的特定情况下,它们可以是合适的替代方案。

Window.scrollByPages() 方法会按指定的页数滚动当前文档。

语法

js
scrollByPages(pages)

参数

pages

要滚动的页数。它可以是正整数或负整数。

返回值

无(undefined)。

示例

js
// scroll down the document by 1 page
window.scrollByPages(1);

// scroll up the document by 1 page
window.scrollByPages(-1);

规范

DOM Level 0。不是规范的一部分。

浏览器兼容性

另见