Right Click on Image

Post Reply
Red Barchetta
Posts: 31
Joined: 27 Sep 2016, 20:45

Right Click on Image

Post by Red Barchetta »

Would it be possible to protect the images, prohibit the right click - copy/save image? And I guess turn off F12 while we are at it?

I know it won't keep everyone from doing it, but it will slow them down. I have someone that keeps stealing my photos, cropping off my watermarks (I put them on the edges so as not to spoil the photo), and then posts them on other sites.

I found this code on the internet :-)

$("body").on("contextmenu",function(e){ return false; }); xxxxxxxxxx. $("body"). ...
$("img").mousedown(function(e){ e.preventDefault() }); xxxxxxxxxx. $("img"). ...
$("#searchresults img").mousedown(function(e){ e.preventDefault() }); xxxxxxxxxx. $("#searchresults img").
And this

document.addEventListener("contextmenu", function(e){
if (e.target.nodeName === "IMG") {
}, false);

Or the likes to only disable the image copy/save?
Site Admin
Posts: 2114
Joined: 02 Mar 2009, 17:02

Re: Right Click on Image

Post by Maksym »

This code will prevent the right-click on the page. But as you already mentioned - it's impossible to protect images that are shown on the page from saving. You can simply use browser main menu item [ Save page as... ] which saves the page along with all images, scripts, stylesheets and everything else. Plus, once the image is shown in browser - browser automatically stores it in the cache on your local hard drive. Later the image can be easily retrieved from that cache...
Post Reply