javascript - Why is jquery beforeunload showing a message even when returning null in Internet Explorer -
this code cause internet explorer show 'are sure want leave?' message every time, when dirtymessage null. doing wrong?
$(window).bind('beforeunload', function() { var dirty = diduserupdatesomething(); if (dirty) { return "you lose changes."; } return null; });
apparently returning null problem. works in other browsers except old ie. solution not return (undefined):
$(window).bind('beforeunload', function() { var dirty = diduserupdatesomething(); if (dirty) { return "you lose changes."; } // notice in case of no dirty message not return anything. // having 'return null;' make ie show popup 'null'. });
Comments
Post a Comment