SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Disabling right click function

    Hi guys,

    I'm not sure if this is the right section, but I have a friend who has his own photography site. He's trying to put off people stealing the images (I've told him its impossible to stop someone doing this) but he would still like the right click function disabled. He has a directory called 'images', which hold all the images on his website.

    Is there a way of assigning a script, which disables the right click function, to this directory, instead of going into each individual page, and adding the script?

    Any help would be appreciated

    Cheers!

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Scripts to disable right click only work sometimes. Scripts to re-enable it always work.

    Trying to disable right click will just annoy legitimate visitors who will then steal the images simply because they are annoyed that someone dared to try to block the functionality of their browser.

    The only way two effective ways to protect images are:

    1. to place a watermark in the image itself and lower the resolution as much as possible.
    2. take legal action against anyone who steals the images.
    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="^$">

  3. #3
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a way of assigning a script, which disables the right click function, to this directory, instead of going into each individual page, and adding the script?
    Sorry this is not possible. You need to put the code on each and every pages.

    As stephen said, I also prefer to watermark your images.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Scripts to disable right click only work sometimes. Scripts to re-enable it always work.

    Trying to disable right click will just annoy legitimate visitors who will then steal the images simply because they are annoyed that someone dared to try to block the functionality of their browser.

    The only way two effective ways to protect images are:

    1. to place a watermark in the image itself and lower the resolution as much as possible.
    2. take legal action against anyone who steals the images.
    Thanks for your reply mate. I've explained this to my friend but he still wants this right click functionality disabled.

    Is it possible to add 1 script to a directory instead of individual pages?

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Not really, unless he is running some sort of server-side scripting where one could include it in the template.

    I think your friend needs to be told to "buzz off" politely. This is just going to annoy legitimate users. Anyone actually after the photographs can still easily get them. Feldgall speaks the truth--just watermark the photos, making it pretty impossible for someone to really abuse them.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Most browsers can also be configured to completely disable any attempt to block the context menu without affecting any of the other JavaScript in the page so the only people who it will stop from being able to bring up the menu will be those who set their browser to allow the page to block it. That menu is not a part of the web page, it is a part of the operating system and therefore it is under the control of the person who owns the computer and not the person who owns the web page.

    The only people who adding the script will annoy are those who don't know enough about the web to use a decent web browser that turns off the ability of web pages to interfere with their browser. They are the sort of people who wouldn't consider stealing the images until you annoy them into doing so. At best they will be annoyed enough to leave the site never to return and will tell all their friends how annoying the site is so that they never visit.

    Anyone going to the site with the intention of stealing the images will not even know that the script is there because they will have turned it off in their browser.
    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="^$">

  7. #7
    SitePoint Enthusiast abercrombie's Avatar
    Join Date
    Jul 2008
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bazza76 View Post
    Thanks for your reply mate. I've explained this to my friend but he still wants this right click functionality disabled.

    Is it possible to add 1 script to a directory instead of individual pages?
    the java script would need to be added to each individual page. i agree with the above, it's very annoying since i personally use right click for navigation and it's so easy to disable java script. if you want to make it more secure, you can go with flash but visitors they can still just hit the print screen button and you'll lose all the data information within the file. do a search on google for a number of scripts:

    java right click disable

  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    you can use:

    window.oncontextmenu = function() {return false};

    which not only disables the right mouse button but also disables the context menu key on the keyboard that brings up the same menu. It only works in browsers more than 10 years old unless the browser owner specifically turns it on in their browser though.

    Any script involving testing onclick will be more complicated than that, will not block the keyboard, and still will only work for really old browsers.
    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="^$">

  9. #9
    SitePoint Zealot
    Join Date
    Dec 2007
    Location
    UK
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used to use these right click scripts but to be honest they are futile and if anyone wants to pinch your image then unfortunately they can do so but to combat this you could put your url on the image which would make people think twice.

  10. #10
    Non-Member eautocad's Avatar
    Join Date
    Jul 2008
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah i wouldn't do it.. if you dont want the public to see it, dont put it on the internet..

    if you post it under a trademarked website (hint hint) there's laws to protect your property...


    get a trademark for your site and include the trademark somewhere in the images or on the page of the images.. people will still steal it, but at least you have legal recourse.

  11. #11
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    relying on copyright, ie legal remedies is just a pain... very often you'll
    1) not even be aware the image has been stolen
    2) it will be stolen by someone overseas who'll ignore legal threats.

    Only way is as suggested above... watermark the image with a faded www.yourdomain.com across the image and reduce the resolution so the stolen image is not useful to them.

  12. #12
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Those stealing the images can just bypass anything that isn't in the image file itself. Only if it is in the actual image itself do they need to take more than a 1/4 second to get a usable copy of the image.
    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="^$">

  13. #13
    SitePoint Guru rageh's Avatar
    Join Date
    Apr 2006
    Location
    London, Formerly Somalia
    Posts
    612
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whether the right click functionality is disabled or not, a determined web user can go to his browser's view menu and get the source of the website. All images visible on the website are referenced there. Very easy to steal.

    However, blocking the right click functionality can deter web users who are not that web savvy. They would not know what else to do if right clicking fails. Therefore it may be worthwhile in its own right as you are deterring quite a lot of people from stealing your images but still your images are not save.

    Disabling right click may annoy legitimate web users but I don't think an annoyed user will resort to stealing just because he cannot use his browser's right click functions. If anything, he will understand why the site owner is doing what he is doing. There are many people who are in the business of stealing. If one can make their work one bit harder, make it by all means. Frustrate them if you can. And as I said earlier those who know their way around can still steal your images but you feel good knowing you have stopped many others in their track.
    ------------------

  14. #14
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Those who steal images don't rely on right clicking or if they do they use a modern browser where the default setting doesn't allow web pages to block their access to the menu. The only possibly effect that trying to block access to that menu can have is to annoy those of your visitors who are running really old web browsers from before browsers stopped supporting the ability to block that menu.

    The best you can hope for in deterring theft of your images through using such a script is zero percent since anyone who intends to steal the images will not even know that it is there. If even one person is annoyed enough to steal your images because you have the script there (no matter how unlikely such a circumstance might be) then you have increased the number of images stolen through using the script rather than prevented any thefts

    The only way to deter people taking your images (which everyone already has a copy of on their computer by the time they see your page) is to watermark the image itself and lower the resolution of the image so that any attempt to remove the watermark will render the image unusable.
    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="^$">

  15. #15
    SitePoint Guru rageh's Avatar
    Join Date
    Apr 2006
    Location
    London, Formerly Somalia
    Posts
    612
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    If even one person is annoyed enough to steal your images because you have the script there (no matter how unlikely such a circumstance might be) then you have increased the number of images stolen through using the script rather than prevented any thefts
    You are missing the point. People who got annoyed because they cannot use the Browser's right click option are not what one is guarding against. They are not visiting your website to steal, and in the unlikely event that they do, then what will they do with that images? Sell them on? No.

    If I steal images to prove a point, I will destroy soon afterwards. And the site owner is not and cannot stop people of such skills from stealing. It is the people with far less skills whose main idea of copying/stealing images is first right clicking and selecting "save image as". If the option is taken away, they(mostly) will go away looking for other site with no hindrance. I am not saying it is a good strategy though.

    The watermarking is far more effective but what I am saying is that not all image stealers are that skillful.
    ------------------

  16. #16
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    All someone wanting to steal your images needs is a modern web browser and your no right click script will be ignored.

    All they need to know is where their browser cache is and they can copy the images from there without needing to worry about protection built into the page.

    All they need to do is to disable active scripting in IE and your script will not work there either.

    If they view the source of your page they can get the address of the image and access it directly in their browser without any of your web page around it.

    There are so many different ways that your images can be taken that a no right click script will not stop anyone who wants to take them. Anyone who wants your images will take them even if you have a no right click script and most will do it in such a way that they are not even aware that you have such a script in the page. The only thing the script will do is to block access to the contextmenu for those novice visitors who wouldn't steal your images but who might use the context menu to navigate between pages. By blocking their access to that menu you are stealing their ability to go back to the previous page, reload the page, print the page, and all sorts of other things that the menu can be used for that have nothing to do with images at all. If the contextmenu is the way that they learned to interact with their browser (and it is much more convenient than having to move the mouse all the way to the top of the screen to get to the alternate copy of the buttons there which they might have turned off to give them a bigger viewing area) then you are denying them the ability to use their browser. At the very least you can expect those newbies to close their browser (since you haven't left them the ability to do anything else), open it again, never return to your site, and tell everyone what a bad site yours is for breaking their browser.

    The point is that "no right click scripts" will NOT stop anyone stealing your images. The script WILL reduce the number of people visiting your site. That is the only measurable effect that such scripts have. If you want to chase people away from your site that badly then you can do it much easier and quicker by deleting your site completely with the added bonus that driving people away that way will also reduce (but not eliminate) people being able to steal your images.
    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="^$">

  17. #17
    SitePoint Guru rageh's Avatar
    Join Date
    Apr 2006
    Location
    London, Formerly Somalia
    Posts
    612
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    All someone wanting to steal your images needs is a modern web browser and your no right click script will be ignored.

    All they need to know is where their browser cache is and they can copy the images from there without needing to worry about protection built into the page.

    All they need to do is to disable active scripting in IE and your script will not work there either.
    Not everybody knows this though. That is my whole point. There are always people who know next to nothing about browsers and scripting. Someone in the know can of course circumvent any measure set to stop theft.
    ------------------

  18. #18
    SitePoint Member
    Join Date
    Aug 2008
    Location
    Sirsa (Haryana) India
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think putting watermark on images is the right way of stopping piracy. Disabling Right Click Option can prevent only novice.

  19. #19
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by rageh View Post
    Not everybody knows this though. That is my whole point. There are always people who know next to nothing about browsers and scripting. Someone in the know can of course circumvent any measure set to stop theft.
    The 47&#37; of people now using browsers other than Internet Explorer don't have to know anything special to bypass a no right click script because their browser will ignore the script by default. Only those using Internet Explorer can have their Operating System interfered with by a web page and at least some of those people would be relying on that menu to navigate between web pages so that blocking it means they have to close and reopen their browser to get to another page (not everyone has the menu bar etc displayed at the top of their screen since the contextmenu gives access to all the same functionality when you right click without taking up space on the screen).

    Overall effect of a no right click script is therefore:
    47% no impact whatever because the script is ignored (this group would include all the image thieves)
    10% no impact whatever because the person knows how to disable it
    30% no impact because the person doesn't ever use it anyway
    10% minor annoyance as preferred way to navigate between web pages not available
    3% major annoyance as only way known to navigate between web pages not available

    Why would you expect someone intending to steal things from your house to enter through the locked front door (IE) when the back door (all other browsers) isn't locked.

    If you lower the resolution of your images to the lowest that is still usable on the web and then watermark them with your domain name then a thief has two choices.
    1. Attempt to remove the watermark - which will lower the resolution of the image further making it effectively unusable or really awful looking if they do use it.
    2. Leave the watermark there ands advertise where they stole the image from.
    That's a WIN for you then even if they do steal your images.
    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="^$">

  20. #20
    SitePoint Zealot nacworld's Avatar
    Join Date
    Aug 2008
    Location
    TEXAS
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    right click script doesn't work on Opera plus if someone really wants that photo they can get it via print screen button.. there is one solution you have to encrypt each photo with javascript..

  21. #21
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacworld View Post
    ...there is one solution you have to encrypt each photo with javascript..
    JavaScript cannot "encrypt" binary data. Nor can it "encrypt" anything for that matter. (Sides I could reverse it so easy its not funny.)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  22. #22
    SitePoint Wizard silver trophy Crazybanana's Avatar
    Join Date
    Mar 2003
    Location
    In tha fruit cellar
    Posts
    1,379
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by logic_earth View Post
    JavaScript cannot "encrypt" binary data. Nor can it "encrypt" anything for that matter. (Sides I could reverse it so easy its not funny.)
    I agree with you, its so easy it's not even funny. it's more like tragic whenever i see someone trying to do so
    Who's to doom when the judge himself is dragged before the bar


  23. #23
    SitePoint Zealot nacworld's Avatar
    Join Date
    Aug 2008
    Location
    TEXAS
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    JavaScript cannot "encrypt" binary data. Nor can it "encrypt" anything for that matter. (Sides I could reverse it so easy its not funny.)
    Hmm but I can encrypt my paypal buy button with a program... and it doesn't allow to see where the image comes from... and on the source code it says "This order button requires a JavaScript-enabled browser." Therefore I thought it could be with JavaScript..


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
  •