back()方法会在会话历史记录中向后移动一页。如果没有上一页,则此方法调用不执行任何操作。

语法

window.history.back()

示例

下述简短示例使页面上的按钮导航页面至会话历史的后一项。

HTML

<button id="go-back">Go back!</button>

JavaScript

window.onload = function(e) {
  document.getElementById('go-back').addEventListener('click', e => {
    window.history.back();
  })
}

规范

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
backChrome 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,