Skip to content

Instantly share code, notes, and snippets.

@madrobby
Created June 24, 2014 12:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madrobby/8dc43c58114466d6a894 to your computer and use it in GitHub Desktop.
Save madrobby/8dc43c58114466d6a894 to your computer and use it in GitHub Desktop.
Code to prevent drag/drop in a Webview inside a Mac app. You can throw this in a `<script>` tag first thing inside the `<body>`. Users will no longer be able to accidentally break your app by dropping something (like a web page URL) onto it.
document.addEventListener('dragover', function(e){
e.preventDefault();
e.stopPropagation();
}, false);
document.addEventListener('drop', function(e){
e.preventDefault();
e.stopPropagation();
}, false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment