In this article I will explain with an example, how to redirect (go) back to Previous Page without Refresh using JavaScript.
It is NOT possible to redirect (go) back to Previous Page without refreshing as whenever Page is redirected there will always be a Page reload in browser i.e. old page will be removed and the new Page from Browser History will be loaded in Browser.
 
 
HTML Markup
Page 1
The HTML Markup consists of an HTML Anchor Link whose HREF attribute is set to Page 2.
<h2>Page 1</h2>
<hr />
<a href="Page2.htm">Redirect to Page 2</a>
 
 
Page 2
The HTML Markup consists of an HTML Anchor Link.
<h2>Page 2</h2>
<hr />
<a href="javascript:;">Redirect back to Page 1</a>
 
 
Redirect (Go) back to Previous Page without Refresh using JavaScript
The HTML Anchor Link in Page 2 is assigned an OnClick event handler and when clicked, it is redirected to the Previous Page using history.back function in JavaScript.
The history.back function
The history.back is an in-built JavaScript function which belongs to the JavaScript window object.
It redirects the Current Page to the Previous Page in the Browser History.
Note: If the Current Page is the First Page in History then there will be no redirection.
 
<h2>Page 2</h2>
<hr />
<a href="javascript:;">Redirect back to Page 1</a>
 
 
Screenshot
Redirect (Go) back to Previous Page without Refresh using JavaScript
 
 
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.

 
 
Downloads