javascript - Avoiding dialog box on beforeunload.. Is it possible? -


i using jquery bind:

$(window).bind('beforeunload', function() {    //code    return "";    } 

if not give return "", works fine in mozilla firefox, ie8. not give alert box saying "are sure want navigate away page?" in google chrome, beforeunload event not work without return "" statement.

and if use return"", gives alert box in broswers.

i not want dialog box , want beforeunload event work. please help. please suggest if there other alternative solution this. thanks.

onbeforeunload has not behaviour consistent across browser

you should set ajax calls async false inside function call in beforeunload event , try ugly hack:

$(window).on('beforeunload', function (e) {     if (e.originalevent)         //call function updating omniture site      else  //this provide enough time other requests send     $.get("", {         async: false     });     $(this).trigger('beforeunload'); //will create kind of infinite loop     //this ugly hack because many useless request send (but nowhere) } 

test , let me know.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -