- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › [Solved] Remove Right-click on images
I can’t seem to find a script to do this and works. I just want to disable right-clicking on images. Preferably in just javascript. The following seems obvious:
$('img').bind('contextmenu', function(e){
alert("We're sorry. Right-Click is not available");
return false;
});
But that doesn’t seem to work completely. Sometimes it’ll still let me click on the first try, but then the following tries it shows the alert.
I don’t want this to be a topic about why you shouldn’t disable right-clicking. I know
Got it. Was very frustrating.
$('img').each(function() {
$(this)[0].oncontextmenu = function() {
alert('We're sorry. Right-Click is not available');
return false;
};
});
That was the quickest post-to-solved thread ever!
Sorry >.>
I kept googling for answers, and came across a bunch of solutions, but every time I tried one of them, it wouldn’t work in one browser or another, so I got frustrated and posted here. And then the next solution I tried worked.
Naturally.
Any developer or anyone with internet smarts can grab any image regardless of how much it’s locked up. But if you work on a site and the client wants their images as protected as possible, you have to do your best to lock them down from as many people as possible.
Ah, Snipping Tool! ;)