--- title: forward() slug: Web/API/History/forward tags: - DOM - HTML5 - History translation_of: Web/API/History/forward ---
在会话历史中向前移动一页。它与使用delta
参数为1时调用 history.go(delta)
的效果相同。
window.history.forward();
下述例子创建了一个按钮,该按钮会在会话历史中向前移动一步。
<button id='go-forward'>Go Forward!</button>
window.onload = function(e) {
document.getElementById('go-forward').addEventListener('click', e => {
window.history.forward();
})
}
Specification | Status | Comment |
---|---|---|
{{SpecName("HTML WHATWG", "browsers.html#history", "History")}} | {{Spec2("HTML WHATWG")}} | No change from {{SpecName("HTML5 W3C")}}. |
{{SpecName("HTML5 W3C", "browsers.html#history", "History")}} | {{Spec2("HTML5 W3C")}} | Initial definition. |
{{Compat("api.History.forward")}}