Window history.back() method
- Previous page back()
- Next page forward()
- Go up one level Window History
Definition and usage
history.back()
The method loads the previous URL (page) from the history list.
history.back()
The method is only valid when there is a previous page.
Note:
history.back()
Same as history.go(-1)
Same.
history.back()
Same as clicking the 'back' button in the browser.
See also:
Example
Create a back button on the page:
<button onclick="history.back()">Back</button>
The output of the above code will be:
Click 'back' to see how it works.
(Only valid when there is a previous page in your history list)
Syntax
history.back()
Parameter
None.
Return value
None.
Browser support
All browsers support history.back():
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous page back()
- Next page forward()
- Go up one level Window History