Created
September 17, 2012 04:46
-
-
Save jsolid/3735617 to your computer and use it in GitHub Desktop.
Display confirmation dialog before exiting/refreshing current page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var processDialog = new YAHOO.widget.Dialog('procDialog', { | |
width: '400px', | |
height: '350px', | |
underlay: 'shadow', | |
visible: false, | |
modal: true, | |
}); | |
window.onbeforeunload = (function() { | |
if ( processDialog.cfg.getProperty('visible') && | |
YAHOO.util.Dom.inDocument('actionMode') && | |
YAHOO.util.Dom.get('processForm').elements['actionMode'].value != 'view' ) | |
{ | |
return 'If you leave now, data you have entered may not be saved.'; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isDataChanged = true; | |
window.onbeforeunload = (function() { | |
if(isDataChanged) { | |
//For IE only, Firefox and Chrome browsers have their own message to display | |
return 'If you leave now, data you have entered may not be saved.'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment