How to capture browser refresh event using javascript
I need to navigate to a specific page / start page of my application when the user clicks the refresh button on any other page of my application. I need a javascript function for this. Someone suggest the best way. thank.
The code I have tried is
window.onbeforeunload = function (evt) {
if (evt) {
evt.stopPropagation();
console.log("refreshed in appBootstrap");
console.log("current url is "+location.href)
window.location.href= "/scm/mgmt/case";
console.log("relocated")
}
}
This does not redirect me to the intended page, but stays on the same page on refresh. I need to go to the specified url every time on the update page.
+3
source to share