• (I’m pretty sure its 2.8 or 2.7)

    I’m working on a website. I have pictures that I’ve taken and don’t want them shared. I want to disable a users ability to right-click on the image (no copy & saving)

    How do I do this?

    Also, if I have a thumbnail that opens a larger photo album, I want the same restrictions applied to those pictures, the album cover & thumbnail

    Thanks in advance.

Viewing 9 replies - 1 through 9 (of 9 total)
  • How do I do this?

    Simple answer? You can’t. If you don’t want people copying your images and/or content, don’t put them on the web. Any supposed solution that disables copying can be broken. Many within a few seconds if you know what you’re doing.

    Consider adding a watermark to your images instead.

    Watermark is the way to go… you’d be wasting your time any other way…

    You can slow users down by using Javascript to disable easy right click copy and paste, but if someone knows what they are doing and enters the image URL directly in their browser, (or uses any number of toolbars out there) you can’t stop them.

    There are PHP ways to obscure image URLs, too. Google will show you.

    But, you can use this meta tag <meta http-equiv="imagetoolbar" content="no" /> to turn off the IE image tool bar, in most cases. And you can use something like this two javascripts in your header ( I don’t know where I orignially got them) to stop casual right clicking:

    <script type="text/javascript">
    <!--
    var message="";
    ///////////////////////////////////
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
    
    document.oncontextmenu=new Function("return false")
    // -->
    
    function disSel(target){
    if (typeof target.onselectstart!="undefined")
    	target.onselectstart=function(){return false}
    else if (typeof target.style.MozUserSelect!="undefined")
    	target.style.MozUserSelect="none"
    else
    	target.onmousedown=function(){return false}
    target.style.cursor = "default"
    }
    </script>
    
    <script type="text/javascript">
    window.onload = function () {
    document.body.onselectstart = function () {
    return false;
    }
    document.body.ondragstart = function () {
    return false;
    }
    }
    </script>

    and then add this in your footer right above the </body> (it works with the second JS) :

    <script type="text/javascript">
    disSel(document.body)
    </script>

    And what if I disable js?

    Can’t win ’em all!

    It;s true that there is no real solution to this – if you put your work on the web there is always a chance that it will be copied. But since the question was how to disable right click, you can replace your <body> tag with this:

    <body onload=”;init_start(); ” id=”bodytag” class=”bodyContent” oncontextmenu=”return false;” >

    But like others said, this does nothing when JS is disabled or if you know how to press Control + U. If you are concerned about hotlinking it may be better than nothing (if you don’t use htaccess to disable it) as some casual hotlinkers may find it inconvenient. Although with firefox’s media tab even that doesn’t seem like much of problem when trying to get the location of bulk images…

    You can get rid of the id and class, didn’t realize I had that in the code.

    The problem with disabling right-click is that you do much more than limit people’s opportunity to casually copy images or text. I use right-click to:

    – bookmark a page
    – examine the page source
    – inspect a page’s, or element’s properties
    – view the page in another browser

    The right-click (context menu) is used in many ways by all kinds of software – some of which could be essential for a given visitor to surf effectively. Disabling this – by force – is rather like me telling you that you can’t use the back door of your own house because you might look over the fence into my garden. At best, it’s unfriendly. At worst, it can be completely disabling.

    I think that developers/site owners should keep their hands off user’s browsers. Full stop.

    Agreed, any site that trys to determine how my browser or mouse behaves either gets their script blocked or loses me a visitor..

    Other users may not feel the same, but i know i find this a major annoyance on some websites.. it may be more so for other people..

    Who knows there may be people out there that still think changing the browsers scrollbar is cool!… lol

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to disable ‘right-click’ features like copy & save’ is closed to new replies.