disabling right click

Discussion in 'Programming' started by saurabhk, Sep 25, 2006.

  1. #1
    How can i disable the right click menu for a webpage?
     
    saurabhk, Sep 25, 2006 IP
  2. vagrant

    vagrant Peon

    Messages:
    2,284
    Likes Received:
    181
    Best Answers:
    0
    Trophy Points:
    0
    #2
    vagrant, Sep 25, 2006 IP
  3. Wekky

    Wekky Active Member

    Messages:
    192
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Place this script between the head tags. Just be aware that these "no right click" type scripts only deter the inexperienced user. There are many ways around them.

    <script LANGUAGE="JavaScript">
    <!--
    function click() {
    if (event.button==2) {
    alert('Right Click Option Not Available!');
    }
    }
    document.onmousedown=click
    // -->
    </script>

    Taken from Webmaster Tools - Black Label Edition II
     
    Wekky, Sep 25, 2006 IP
  4. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #4
    To be honest, I wouldn't bother disabling right-click. It tends to annoy the user and is very easy to overcome.
     
    mcfox, Sep 25, 2006 IP
  5. dastuff

    dastuff Peon

    Messages:
    475
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would highly agree... If you want to protect your content do it in a less obtrusive way... And it is very easily overcome :)
     
    dastuff, Sep 25, 2006 IP
  6. saurabhk

    saurabhk Peon

    Messages:
    149
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks to all for replying.
     
    saurabhk, Sep 25, 2006 IP
  7. KLB

    KLB Peon

    Messages:
    1,167
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Also keep in mind browsers like Firefox are getting better about providing an option that allows users to prevent websites from screwing with the right mouse click.

    Again don't mess with the right mouse click. There are too many legitimate reasons users have for wanting to use it.
     
    KLB, Sep 27, 2006 IP
  8. Drew007

    Drew007 Peon

    Messages:
    310
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    So what is the best way to protect your content?
     
    Drew007, Sep 27, 2006 IP
  9. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You can't protect your html content. Thats the nature of the web.
     
    mad4, Sep 27, 2006 IP
  10. KLB

    KLB Peon

    Messages:
    1,167
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #10
    As Mad4 said in his comment you can't if it is in HTML format. There is no techical trick that you can do that will stop someone from copying the content of a webpage. There are lots of "tricks" people try to deploy, but they all are child's play to circumvent.

    The best that you can do is post a very obvious copyright statement and track down sites that steal your content via services like Copyscape.com.
     
    KLB, Sep 27, 2006 IP
  11. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #11
    If you are really determined to protect your content you could always create it in a drawing program and save it as a graphic. This gives you absolute control over the final look of the page, right click does nothing meaningful, and people cannot highlight and copy the text.

    You could also look displaying all content through Java applets. Once again, you assume full control over whether content can be copied and the way it is cached on the user's machine.

    I have also heard of people using javascript to write the content of the page to the screen. If people disable javascript, the text is garbled in some manner -- written backwards or otherwise encrypted.

    None of these approaches is fool-proof. But all add a good measure of annoyance to people trying to steal your content and perhaps even to ordinary visitors.

    But, at the end of the day, are you actually producing something that is worth going through this much effort to protect? If so, actively forcing sites which steal your content to remove it or face being shut down is the best possible solution.

    On the other hand, if your content is good, allowing limited use of your content -- for instance through RSS feeds with links back to your site -- turns a perceived problem into an opportunity to promote your site.
     
    clancey, Sep 27, 2006 IP