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
Parameters
Return value
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
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
back |
1 |
12 |
1 |
10 |
≤12.1 |
1 |
4.4 |
18 |
4 |
≤12.1 |
1 |
1.0 |
See also