My application is developed in react. I have a form , when my user tries to reload I have to disable brower's
default popup and show my own custom popup.
I tried with "onbeforeunload" and "beforeunload" events , I can able to prevent brower's default popup by giving
window.onbeforeunload = null;
But I have to prevent brower's default alert and show my custom alert with ok and cancel button.
Is there anyway I can detect my brower is getting reloaded ?
Can someone help me on this.Thanks in advance.
did you try calling event.preventDefault() inside onbeforeunload listener?
like:
window.onbeforeunload = e => {
e.preventDefault();
// ... your custom logic
}
Let me know if it works
stackoverflow.com/a/276739/19111 Unfortunately you can't change or remove the window modal. The only change can be done is the message displayed.
Arooj Fatima
Hello, Hope you're doing well Can you please help me in this I'm working on it and stuck from last week
Thank you, Best Regards, Arooj Fatima