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

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -