JavaScript history.back() Method

You are Here:

JavaScript history.back() Method

The history.back() method loads the previous URL in the history list.

This method is similar to your browser's back button on the top left corner.

Example

Consider the following example as page 1.

HTML Online Editor
<!DOCTYPE html> <html> <body> <h1>Page 1</h1> <button onclick="myFunction()">Go Back</button> <script> function myFunction(){ window.history.back(); } </script> </body> </html>

Consider the following example as page 2.

HTML Online Editor
<!DOCTYPE html> <html> <body> <h1>Page 2</h1> <button onclick="myFunction()">Go Back</button> <script> function myFunction(){ window.history.back(); } </script> </body> </html>

Consider the following example as main page.

HTML Online Editor
<!DOCTYPE html> <html> <body> <a href="/page1">Page 1</a> <a href="/page2">Page 2</a> </body> </html>

Syntax

window.history.back()

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author