History:forward() 方法
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
History
接口的 forward()
方法使浏览器在会话历史中向前移动一页。它的调用效果与 history.go(1)
相同。
语法
js
forward()
参数
无。
返回值
无(undefined
)。
异常
SecurityError
DOMException
-
如果关联的文档未完全激活,则会抛出此异常。浏览器还会限制导航操作,如果调用过于频繁,可能会抛出此错误、生成警告或忽略该调用。
示例
以下示例创建了一个在会话历史中向前移动一步的按钮。
HTML
html
<button id="go-forward">前进!</button>
JavaScript
js
document.getElementById("go-forward").addEventListener("click", (e) => {
history.forward();
});
规范
Specification |
---|
HTML # dom-history-forward-dev |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
forward |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.