Results 1 to 2 of 2

Thread: Disable right click

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

    Default Disable right click

    I have a webpage with photo thumbnails. The following script disables right click on the thumbnails but not on the actual photo when it is enlarged (by clicking) from the thumbnail. It is the actual photo that I would like to protect. Any ideas on how to disable right click on the photo that pops up in another window?

    I'm using Yahoo SiteBuilder.

    <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="Copyrights do not allow this function."

    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>

  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

    Put the disable script on the page that the photo that you want to use it with is on. If the photo isn't on a page, you will have to make a page for it, generate one at the time it is displayed, or use an alternate display method for it, where the disabling script can apply. Just for your information, these disabling scripts do nothing to protect your image from being copied. If that is all you want it for, forget about it.
    - John
    ________________________

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

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
  •