1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

right click disabling on a picture

Discussion in 'Software Development' started by Ian Price, Apr 19, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. Ian Price

    Ian Price Thread Starter

    Joined:
    Apr 27, 2003
    Messages:
    63
    <script language="JavaScript">
    function click() {
    if (event.button==2) {
    alert('Hey, leave my images alone!');
    }
    }
    document.onmousedown=click
    // -->
    </script>


    this coding works fine for my index.html page where all my thumbnail pictures are.

    When a user clicks on one of these thumbnail pictures, the picture loads the large version. But when the large picture is on screen, the user can right click on it.

    How can I prevent the user from right clicking on the large picture (because that’s the one I need protecting really!)


    ie.. how do i disable right clicking on this picure?
    http://www.iprice.f2s.com/photos/900Dscf0156.jpg
     
  2. mussavcom

    mussavcom

    Joined:
    Mar 28, 2004
    Messages:
    51
    Make it, instead of loading the large version, open another HTML document with the JavaScript you posted above and then with an img tag with the large image.

    Remember, though, there are still several ways to get the image, most of which you can't stop.
     
  3. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    You are wasting your time trying to prevent the right-click. That won't help at all. There are lots of other ways to get the pic(s), not to mention that some browsers can be set so that javascript doesn't affect the right-click function.

    As always said before, if we can see it, we can get it. Most n00bies can get around the right-click anyway. It's not gonna help you at all. What if the visitor has javascript turned off? etc. etc.
     
  4. Ian Price

    Ian Price Thread Starter

    Joined:
    Apr 27, 2003
    Messages:
    63
    ye, fair enough. you could even do a "print screen" ;)
    thanks anyway :)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/221828

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice