Rahul Munjal
Rahul Munjal

Reputation: 2693

Refresh browser on click of back button JS

I am creating an application which has a requirement of refreshing the browser whenever we click back button to try to go back to some other page.

How can i do that ? Is there any way to catch the back button event ?

Thanx in advance..

Upvotes: 0

Views: 1951

Answers (2)

dakab
dakab

Reputation: 5875

If you implement the HTML5 History interface, you can react to onpopstate and then just reload() the page.

Upvotes: 1

wero
wero

Reputation: 32980

You can try to use the popstate event:

window.onpopstate = function(event) {
    window.location.reload();
};

Upvotes: 0

Related Questions