my web-app has this:
$(window).bind('beforeunload', function() {
if(unSavedChanges == true)
{
return 'You have unsaved changes';
}
return null;
});
this works fine in Safari and Firefox (with the exception that firefox does not show my custom message in it's onBeforeUnload dialog). However on IE 8 on Windows 7, it always shows the onBeforeUnload notification, specifically if there are no unsaved changes, it would just say "null". How can I prevent IE from showing onBeforeUnload notification when user has saved everything and wants to navigate away?
as per Jon's suggestion, I have removed the return null line, the code now reads
$(window).bind('beforeunload', function() {
if(unSavedChanges == true)
{
return 'You have unsaved changes';
}
});