Window history.back() Method
- Previous Page back()
- Next Page forward()
- Go to the Previous Level Window History
Definition and usage
history.back()
The method loads the previous URL (page) in the history list.
history.back()
The method is valid only when there is a previous page.
Note:
history.back()
With 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.
(Valid only 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 to the Previous Level Window History