/    Sign up×
Community /Pin to ProfileBookmark

protecting images from download

Hi,
Am trying to protect images from being downloaded – I used the following script and although it does give the JS Alert, it still lets you download the page – what am I missing? Thanks!
[COLOR=DarkSlateBlue]

[CENTER]


<!– TWO STEPS TO INSTALL PROTECT IMAGES:

  • 1. Copy the coding into the HEAD of your HTML document

  • 2. Add the onLoad event handler into the BODY tag –>
  • <!– STEP ONE: Paste this code into the HEAD of your HTML document –>

    <HEAD>

    <SCRIPT LANGUAGE=”JavaScript”>

    <!– This script and many more are available free online at –>
    <!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>

    <!– Begin
    function protect(e) {
    alert(“Sorry, you don’t have permission to right-click.”);
    return false;
    }

    function trap() {
    if(document.images)
    for(i=0;i<document.images.length;i++)
    document.images[i].onmousedown = protect;
    }
    // End –>
    </SCRIPT>

    <BODY OnLoad=”trap()”> ….

    [/CENTER]

    [/COLOR]

    Thanks

    to post a comment
    JavaScript

    4 Comments(s)

    Copy linkTweet thisAlerts:
    @Banaticus407Apr 20.2005 — You know, even if you get that code working, a person (not me!) could still steal your images, right? I have a really big/good monitor with good resolution. If I wanted a picture I would only have to print screen, copy the image into the default paint program that comes with Windows, crop out everything but your image, and presto. I have your image. Edit: When I say "print screen" I don't mean actually print with a printer, but copy a picture of the screen to the clipboard.

    Even with a normal 17" monitor and 1024x768 sizing, the image doesn't lose any more resolution than saving it as a .jpg would (so, it doesn't really lose any quality).

    For information on how to [B]really[/B] stop someone from stealing your pictures, go here:

    http://www.webdeveloper.com/forum/showthread.php?t=26841

    Now, to get to your actual code.

  • 1. Your code advertises for some website. Get rid of the ad -- unless you borrowed the code from that site and are trying to get it to work, or you're one of the people behind that site and have no idea what you're really doing.

  • 2. Your code has "code words" -- words that sound "cool" when you're looking at the source code but that don't add anything to the readability of your code. Get rid of those, or rename them to something appropriate.

  • 3. The document.images array only reflects the <img> tags. It doesn't show any images created with the Image() constructor. In other words, if you preloaded images used with onMouseRollover in the head of the document, or if you used the Image() constructor in anything else, those pictures won't be "protected".

  • 4. That "onMouseDown" event that you're trying to use doesn't work with Opera -- a browser that lacks some of the security holes that Internet Explorer has (although, it lacks of the nice features that IE has as well).


  • Try this site to at least stop someone from using your bandwidth:

    http://www.thesitewizard.com/archive/protectimages.shtml

    For more help on protecting an image see:

    http://www.urban75.org/tech/protect_3.html

    http://www.htmlite.com/faq010.php

    http://www.digitalmidget.com/help/noclick/index.php

    Note that you can never completely stop someone who is determined from taking your image.
    Copy linkTweet thisAlerts:
    @Lightfoot82Apr 20.2005 — I Agree,

    Just read through your code, not being funny but the code is absolutely useless, If you are going to post code and offer help at least make sure it is useful and not useless.

    And as for advertising the Java Script Site?????
    Copy linkTweet thisAlerts:
    @sparqApr 20.2005 — Maybe he is new to the internet and doesnt understand how computers work???????

    in IE, unlinked images you can just drag up into the address bar to view them (same thing as viewing from cache)
    Copy linkTweet thisAlerts:
    @tutumomauthorApr 21.2005 — First, Thanks for all who replied and I just want to [B]THANK[/B] Sparq of thinking that I might be a newbie - I AM! And that's why I am asking for help!

    >>Just read through your code, not being funny but the code is absolutely >>useless, If you are going to post code and offer help at least make sure it is >>useful and not useless.

    >>And as for advertising the Java Script Site?????


    Having said that, I didn't write this code. It was posted somewhere (and I can't find the link right now) on the web and I just tried it. I cut and paste the whole code in case I was missing something...

    And Banaticus407, yes I know that you can't really protect them fully but I am working with someone who would at least like to prevent them at the first go and most of the people that will be looking at his site are not super computer users who will know CTRL PRINT etc.
    ×

    Success!

    Help @tutumom spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...