history.back()
The history.back()
method is part of the JavaScript History API. It allows you to programmatically navigate to the previous page in the browser's session history, similar to clicking the browser's back button.
When you call history.back()
, the browser will load the previous page in the session history. This is equivalent to the user clicking the back button in their browser.
Here's a simple example of how to use history.back()
in JavaScript:
<button onclick="goBack()">Go Back</button>
<script>
function goBack() {
window.history.back();
}
</script>
history.back()
will have no effect.history.forward()
and history.go()
.