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?
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?
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();
}
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);