Skip to content

Instantly share code, notes, and snippets.

@digitalhydra
Created December 13, 2013 16:44
Show Gist options
  • Save digitalhydra/7947184 to your computer and use it in GitHub Desktop.
Save digitalhydra/7947184 to your computer and use it in GitHub Desktop.
execute something before user leave the page before unload javascript
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment