★ Snippet O’ the Week: Disable Right-Click Completely with jQuery
August 24th, 2011 | by Patrick Cox | Published in Design, Development, Snippet O' the Week | 9 Comments
This is a snippet I’ve been looking for for a very long time now but have never found a legit solution. Some script functions do a warning pop up or only partially disable right-click, but this little snippet completely disables it. To disable right-click is really great if you are trying to protect photos from getting stolen or things like that and I know a lot of designers and developers hate when a web site takes control over basic browser functions. But privacy is becoming a huge deal on the internet and in some case its important to protect yourself, your images and your designs from being blatantly stolen right off your digital property.
Here’s the snippet, sweet and simple – oh, don’t forget to include jQuery: (big thanks to Codrops.com for this fantastic snippet)
<script>
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
</script>

August 28th, 2011at 8:27 pm(#)
Thanks for the snippet. I seldom run scripts that prevent browser behavior but I did have a client ask for this in the past and I was never able to pull it off. But this works great.
September 3rd, 2011at 7:39 am(#)
Very nice! I adapted it to disable right-click on images only (so visitors can still open links in new tabs and copy text):
$(‘img’).ready(function(){
$(‘img’).bind(“contextmenu”,function(e){
return false;
});
});
Thanks for the code!
September 3rd, 2011at 7:42 am(#)
Oh shoot, let’s try that again shall we:
{script type=”text/javascript”}
$(‘img’).ready(function(){
$(‘img’).bind(“contextmenu”,function(e){
return false;
});
});
{/script}
(replace braces with inequality signs or look here http://www.webdeveloper.com/forum/showthread.php?&t=249801&is_resolved=1)
September 3rd, 2011at 9:35 am(#)
Sweet, that is awesome thanks! I like that better.
September 3rd, 2011at 11:58 am(#)
You’re welcome. Thank you for the snippet, been looking for a valid JS doing this for a while :)
September 26th, 2011at 3:29 pm(#)
Useless…
All The user has to do is to turn off js.
So… It protects nothing and bothers everyone.
Nice job !
Btw, The web is OPEN, it is a place to SHARE. If you Wang to enforce your copyright on pictures, there are plenty solutions like watermarking or going full-flash.
October 5th, 2011at 3:33 pm(#)
or use
$(document).ready(function(){
$(this).bind(“contextmenu”,function(e){
return false;
});
});
November 20th, 2011at 7:27 am(#)
Doesn’t work in FF8
November 20th, 2011at 7:29 am(#)
Even in older versions it only takes three mouse clicks to disable it.
Another pointless script.