how to refresh page when "back" button is clicked vue.JS
Hello ,
I'm wondering how to refresh the page when user clicks browser back button ?
thanks
So, it's pretty hard to actually refresh the page whenever you click on the back button. However, it's possible with a small work around.
This should work on most browsers
window.onpopstate = function () {
location.reload()
};
Note: I said most browsers, in some edge cases it might not work. This is the hard part about controlling the history of a browser ;)
Thank you bro! This answers is work fine for me!
this code works perfectly for all browsers
window.addEventListener("pageshow", function(event) {
var historyTraversal = event.persisted ||
(typeof window.performance != "undefined" &&
window.performance.navigation.type === 2);
if (historyTraversal) {
// Handle page restore.
window.location.reload();
}
});
Please or to participate in this conversation.