Skip to main content

Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #33141
    noahgelman
    Participant

    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

    #72799
    noahgelman
    Participant

    Got it. Was very frustrating.

    $('img').each(function() {
    $(this)[0].oncontextmenu = function() {
    alert('We're sorry. Right-Click is not available');
    return false;
    };
    });
    #72800
    TheDoc
    Moderator

    That was the quickest post-to-solved thread ever!

    #72714
    noahgelman
    Participant

    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.

    #72724
    noahgelman
    Participant

    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.

    #72730
    Brightonmike
    Member

    Ah, Snipping Tool! ;)

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.