How To Show A Modal Dialog Before Beforeunload Shows Its Own?
I do understand that it's not possible to replace the beforeunload dialog with a custom one, and that if we need to set a custom message to the user, we'll have to return a string
Solution 1:
The DOM modifications take effect only when your script ends execution. In this case, the native dialog is fired first for obvious security reason.
Note that due to the many security problem introduced by this unspecified feature (see the MDN doc), it will maybe be removed (the soonest the best in my opinion), the old reason to have it (save the data) being obsolete in the age of ajax.
Solution 2:
unload and onBeforeUnload are very not cross-browser events. Be careful. It's not work in Opera and sometimes in Chrome.
Post a Comment for "How To Show A Modal Dialog Before Beforeunload Shows Its Own?"