Results 1 to 6 of 6

Thread: Disable right mouse click script II (on images)

  1. #1
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Disable right mouse click script II (on images)

    1) Script Title:
    Disable right mouse click script II (on images)

    2) Script URL (on DD):
    <script language="JavaScript1.2">

    /*
    Disable right click script II (on images)- By Dynamicdrive.com
    For full source, Terms of service, and 100s DTHML scripts
    Visit http://www.dynamicdrive.com
    */

    var clickmessage="Right click disabled on images!"

    function disableclick(e) {
    if (document.all) {
    if (event.button==2||event.button==3) {
    if (event.srcElement.tagName=="IMG"){
    alert(clickmessage);
    return false;
    }
    }
    }
    else if (document.layers) {
    if (e.which == 3) {
    alert(clickmessage);
    return false;
    }
    }
    else if (document.getElementById){
    if (e.which==3&&e.target.tagName=="IMG"){
    alert(clickmessage)
    return false
    }
    }
    }

    function associateimages(){
    for(i=0;i<document.images.length;i++)
    document.images[i].onmousedown=disableclick;
    }

    if (document.all)
    document.onmousedown=disableclick
    else if (document.getElementById)
    document.onmouseup=disableclick
    else if (document.layers)
    associateimages()
    </script>

    3) Describe problem:
    It doesn't work for me. I'm not sure what I am doing wrong. Please help.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm not sure what I am doing wrong. Please help.
    That's easy, using the script. That's what you are doing wrong. Seriously, this type of script often doesn't work and always adds weight to your page. Even when it does work, the images can be easily copied in several alternative ways. Copyright is the only foolproof method of protecting your images and the good news is that - original images (and all original material) is copyright just by virtue of being published on the web.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you, John. I am aware that they can still copy. My goal is to make it hard for someone to inadvertently copy my images. A lot of people don't realize that the images are copyrighted because of the "toolbar" and "right click" options make it look like it's okay to copy.
    I was able to disable the toolbar, until I started nesting frames. I do know there are a lot of websites out there that successfully disabled the "right click" option and give an alert notice. I'd really like to try to make it work.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <script type="text/javascript">
    window.onload = function() {
      for(var i = 0, e = document.images; i < e.length; ++i)
        e[i].onmousedown = function(e) {
          var ev = e || window.event;
          if(!ev) return;
          if((ev.srcElement || ev.target).tagName.toLowerCase() == "img")
            if (ev.button &&
              (ev.button == 2 || ev.button == 3)
            ) {
              alert(clickmessage);
              return false;
            } else if(ev.which && ev.which == 3) {
              alert(clickmessage);
              return false;
            }
            return true;
        };
    };
    </script>
    However, there are still better ways to advertise your copyright. If people don't notice it, it evidently doesn't stand out enough. One good trick is to set the title attribute of the images to something like "Warning: this image is copyrighted. See copyright notice at bottom of page." That way, if somebody using IE hovers their mouse over it to get the image toolbar, they'll see that message as well.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jul 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please forgive my ignorance, but I just starting teaching myself GoLive so I can build my own website. Can you please elaborate on how to "title" something?

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <img src="image.png" title="Warning: this image is copyrighted.  See copyright notice at bottom of page.">
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •