Last active
December 29, 2015 17:48
-
-
Save daveshah/7706316 to your computer and use it in GitHub Desktop.
tiny little snippet for disabling copy/paste
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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!"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Earlier versions of the above used$(this) instead of $ ('#foo') - it turns out, this didn't work out so well in IE.