I need to navigate to a particular page/start page of my application when user clicks on refresh button in any other page of my application.I need javascript function for this.Can anyone suggest the best possible way. thanks.
The code i 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 rather remains in the same page on refresh.I need to navigate to the specified url on page refresh each time.
You can try a counter kind of thing. if counter is 2 than redirect to your required page.
or you can try document.referrer
but some browser may not support this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With