I have the following code in onbeforeunload function.
window.onbeforeunload = function(){
if(ThereIsUnsavedWork)
{
return "Please save your work so it doesn't get lost.";
}
DoMoreStuff();
}
After the confirmation window, the DoMoreStuff() function isn't getting executed. Is there a way to make sure that javascript code executes after user accepts the confirmation window?
Try to use onbeforeunload together with onunload as below.
window.onbeforeunload = function(){
if(ThereIsUnsavedWork)
{
return "Please save your work so it doesn't get lost.";
}
}
window.onunload = function () {
DoMoreStuff();
}
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