forward()
在会话历史中向前移动一页。它与使用delta
参数为1时调用 history.go(delta)
的效果相同。
语法
window.history.forward();
示例
下述例子创建了一个按钮,该按钮会在会话历史中向前移动一步。
HTML
<button id='go-forward'>Go Forward!</button>
JavaScript
window.onload = function(e) {
document.getElementById('go-forward').addEventListener('click', e => {
window.history.forward();
})
}
规范
Specification | Status | Comment |
---|---|---|
HTML Living Standard History |
Living Standard | No change from HTML5. |
HTML5 History |
Recommendation | Initial definition. |
浏览器兼容性
BCD tables only load in the browser