Skip to content

Instantly share code, notes, and snippets.

@filipkral
Created November 13, 2013 00:04
Show Gist options
  • Save filipkral/7441074 to your computer and use it in GitHub Desktop.
Save filipkral/7441074 to your computer and use it in GitHub Desktop.
Stay on page. I use this to prevent me from leaving ArcGIS API for JavaScript Sandbox (http://developers.arcgis.com/en/javascript/sandbox/sandbox.html) accidentally by pressing escape when the focus is not on the code editor.
// to open a confirm dialog before you leave the page, enter this into the browser console (or the javascript code)
window.onbeforeunload = function(e){ var e = e || window.event; var msg ="Don't leave!"; if(e){e.returnvalue = msg;} return msg; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment