SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Disable right click help needed

    I am wanting to know how can I make this script, have the right click menu be disabled for all other browsers - Firefox, Opera, etc?

    Code JavaScript:
    function right(e) {
    if (navigator.appName == 'Netscape' && 
    (e.which == 3 || e.which == 2))
    return false;
    else if (navigator.appName == 'Microsoft Internet Explorer' && 
    (event.button == 2 || event.button == 3)) {
    alert("Sorry, these images are copyright protected.");
    return false;
    }
    return true;
    }
     
    document.onmousedown=right;
    document.onmouseup=right;
    if (document.layers) window.captureEvents(Event.MOUSEDOWN);
    if (document.layers) window.captureEvents(Event.MOUSEUP);
    window.onmousedown=right;
    window.onmouseup=right;

    Does anyone have any other suggestions to prevent website visitors, from saving photos to their computer?

    Thanks in advance.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    This is one of the many should I/Shouldn't I things on the internet. Like music that plays when you arrive on the site - some love it, some hate it.

    My own personal advice is not to waste your time trying to stop the right click event - if I want your images then I can get them. Its only personal preference but I really hate it when someone tries to control something that is mine, ie my mouse. I use the right click for more than saving links and images and to have it interefered with is just plain annoying!

    Think of other ways to stop them images being used - watermarks perhaps?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Instead of checking for the navigator.appName, you would check for e.which or event.button (which is the better way of doing this anyway), but as Spike says, this is quite anti-social and in fact, when this is done, I actually enjoy circumventing the block to get what I want.

    At the end of the day, if you don't want people stealing your images, watermark them or make them small enough that they can be seen but look bad if they are blown up.

  4. #4
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Disabling right click won't prevent them, there are other ways they can copy the image and there's no JavaScript solution to prevent all of them... they could drag and drop the image from the browser window to their desktop, they could go through the source code to get the image URL and download it directly, they could use a Firefox plug-in to grab the file, they could go to the browser cache and simply copy the downloaded image, they could use their print screen button (outside of the browser) and take an exact snapshot of the file, they could disable scripting and then right click and save the image, the list is endless. If it's on the web it can't be bolted down. If you don't want it copied, don't upload it. The only people right click cripple scripts affect are legitimate users.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Opera turns off the ability to disable right click by default so you would need your visitors to deliberately change their settings in order to allow it to be disabled.

    Even for those browsers that don't provide a simple way within the browser to turn off disabble right click scripts it is trivial to install a bookmarklet that can be run against any web page to turn it back on again (without having to turn off JavaScript completely)
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •