Results 1 to 8 of 8

Thread: How to disable right-click on images w/o alert message?

  1. #1
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to disable right-click on images w/o alert message?

    Could anyone tell me the code to disable right-clicking on images WITHOUT an alert message popping up?

    Now i using this code

    Code:
    <script language="JavaScript1.2"> 
    
    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>
    how to disable "Right click disabled on images!" from this code

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    There's no point, and this is just annoying.
    If you insist on pretending to protect your images (and trust me, it is just pretending) you can google for a lot of codes, and there are some on this website.
    However, it will not work on every OS/browser, and you also won't actually protect anything... at all.
    You'll stop the stupid people, but the real thieves will know how to get around it. Additionally, you'll just annoy a lot of people who don't mean to cause you harm, but might want to look at the image, or save it (but not to hurt you), or just have a habit of clicking and suddenly find that their mouse button isn't working...
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is the any chance you answer me to that question ?

    p.s I ask google and no Joy

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    http://www.google.com/search?q=no+right+click+no+alert
    Took me 4 seconds to type that.
    And, look, fifth link:
    http://www.java-scripts.net/javascri...ut-Alert.phtml

    And the answer is still that you're wasting your time. If this sounds harsh, then I'm sorry for that, but it's the truth and someone needs to tell you. You can't protect the images. Everyone tries, everyone fails, then figures out it's not worth it. Just trying to speed it along for you. Not that your idea is bad.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    this is not for image ... this diseble right click on all web page

    i want just for images and yes i know this is not sense but i have to do it for my expirience

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, the search certainly has a lot of results.
    http://www.dynamicdrive.com/dynamicindex9/noright2.htm

    But that doesn't work in NS4+ (including FF).

    Keep searching, but as I've said, you'll find that none of them work fully, so you won't ever find "it".
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Once you publish something in your site it becomes very difficult to protect them in a meaningful manner especially the images. Mostly the people used to disable the right-clicking just to protect their image. But unfortunately you won't be able to protect the images in this manner as the user can take the images using different other techniques like they can save the page and under normal circumstances the image will be downloaded to their PC or they can use some screenshot takers for getting the images without much difficulty.

    As Daniel pointed out it is almost impossible to protect your images by diabling the right click.

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    And to be fair, perhaps you have another purpose for this. If that is the case, then explain that, not just that you want a working no right click script, and maybe there's a way around it. There are a few occasions where something like this can help, and sometimes some solutions, too.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •