var confirmOnPageExit =function(e){
// If we haven't been passed the event get the window.event
e = e || window.event;
var message = 'Any text will block the navigation and display a prompt';
// For IE6-8 and Firefox prior to version 4
if(e){
e.returnValue = message;}
// For Chrome, Safari, IE8+ and Opera 12+
return message;};
window.onbeforeunload = confirmOnPageExit;
// Turn it on - assign the function that returns the string
window.onbeforeunload = confirmOnPageExit;
// Turn it off - remove the function entirely
window.onbeforeunload = null;