JavaScript History API - Go Back Function

Understanding 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.

How it Works

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.

Usage Example

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>
        

Important Considerations

Return to Home Page

Go Back

✏️ Edit Page