How to reload page if user has returned in browser history

0

I have a problem, that when the user clicks the back button in the browser menu, it goes to the previous page, but it does not reload and maintain the old content. How can I reload it when this event happens?

    
asked by anonymous 09.03.2017 / 18:29

2 answers

0

I found the answer to the question. When the "window.performance.navigation.type" object equals 2, it means that the user came from a later page through the browser history.

if (window.performance && window.performance.navigation.type == 2) {
    window.location.reload();
}
    
10.03.2017 / 14:03
-1

There is no event that detects if the user clicked the back button in the browser history, so I believe the best way is to work with SESSION .

When accessing a page, you fill a SESSION , if the user revisits this page you check the SESSION , if he has already accessed you can use: location.reload();

I do not know what language you are using, but in C # to call the script on the back end you can use the following code: Page.ClientScript.RegisterStartupScript(this.GetType(), "reloadPage", "location.reload();", true);

    
09.03.2017 / 18:42