Is it possible for onbeforeunload()
function to wait for ajax result and move to a jsp based on the resultvalue or atleast show a message before unloading?
AFAIK, it is not possible. onbeforeunload
has very limited functionality, otherwise malicious sites could stop you from leaving their site.
Addendum: It is possible to show a message like 'You are leaving this page'. In that case, the beforeunload()
function must return a string.
Example
window.onbeforeunload = function() {
return 'Are you sure about that?';
}