在会话历史中向前移动一页。它与使用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.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
forwardChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

文档标签和贡献者

标签: 
此页面的贡献者: C1er
最后编辑者: C1er,