Window history.back()
Example
Create a back button on a page:
<button onclick="history.back()">Go Back</button>
The output of the code above will be:
Click on Go Back to see how it works.
(Will only work if a previous page exists in your history list)
Definition and Usage
The history.back()
method loads the previous URL (page) in the history list.
The history.back()
method only works if a previous page exists.
Note
history.back()
is the same as history.go(-1)
.
history.back()
is the same as clicking "Back" your browser.
See Also:
Syntax
history.back()
Parameters
NONE |
Return Value
NONE |
Browser Support
history.back()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |