I need to call a JS function when user closing the browser tab. the problem is i want t
JSFiddle uses the following to alert the user they are trying to close their modified fiddle without saving:
window.onbeforeunload = function(){
if (window.editorsModified){
return "You've modified your fiddle, reloading the page will reset all changes."
}
};
This works reliably (http://jsfiddle.net/MaxPRafferty/b6uEF/show/ ,Latest Chrome, FF, IE10 ), but will always prompt the user. You can't force the page open by returning false;