Onbeforeunload And Onunload Getting One To Work After The Other
I am having some trouble with the on before unload and the unload method. I thought i set the code right in terms of the onload method only firing up after the confirm method for o
Solution 1:
onbeforeunload
does not work like you think it does. You can return a string from the handler, which will prompt a messsage, or undefined
which will do nothing.
window.onbeforeunload = goodbye;
functiongoodbye(e) {
if (!validNavigation) {
return leave_message;
} else {
returnundefined;
}
}
Related: Way to know if user clicked Cancel on a Javascript onbeforeunload Dialog?
Post a Comment for "Onbeforeunload And Onunload Getting One To Work After The Other"