1window.addEventListener("beforeunload", function (e) {
2 var confirmationMessage = 'It looks like you have been editing something. '
3 + 'If you leave before saving, your changes will be lost.';
4
5 (e || window.event).returnValue = confirmationMessage; //Gecko + IE
6 return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
7});