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。不是規範的一部分。

瀏覽器相容性

另見