The History.back()
method causes the browser to move back one page in the session history. It has the same effect as calling history.go(-1)
. If there is no previous page, this method call does nothing.
This method is asynchronous. Add a listener for the popstate
event in order to determine when the navigation has completed.
Syntax
history.back()
Examples
The following short example causes a button on the page to navigate back one entry in the session history.
HTML
<button id="go-back">Go back!</button>
JavaScript
document.getElementById('go-back').addEventListener('click', () => {
history.back();
});
Specifications
Specification | Status | Comment |
HTML Living StandardThe definition of 'History.back()' in that specification. | Living Standard | No change from HTML5. |
HTML5The definition of 'History.back()' in that specification. | Recommendation | Initial definition. |
Browser Compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
back
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support Yes |
IE
Full support 10 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
See also
History.back() by Mozilla Contributors is licensed under CC-BY-SA 2.5.