Skip to content

Instantly share code, notes, and snippets.

@daveshah
Last active December 29, 2015 17:48
Show Gist options
  • Save daveshah/7706316 to your computer and use it in GitHub Desktop.
Save daveshah/7706316 to your computer and use it in GitHub Desktop.
tiny little snippet for disabling copy/paste
$(function () {
$('#foo').bind("contextmenu", function (e) {
e.preventDefault();
alert("Copy is not allowed!");
});
$('#foo').bind('copy', function(e) {
e.preventDefault();
alert("Copy is not allowed!");
});
$('#foo').bind('paste', function(e) {
e.preventDefault();
alert('Paste is not allowed!')
});
$('#foo').bind('cut', function(e) {
e.preventDefault();
alert("Copy is not allowed!");
});
});
@daveshah
Copy link
Author

Earlier versions of the above used $(this) instead of $('#foo') - it turns out, this didn't work out so well in IE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment