/    Sign up×
Community /Pin to ProfileBookmark

Protect images script conflicts with my javascript menu

Ive used the protect script to stop people clicking on my images and saving them.

This has stoped the javascript menu i have on the same page from working. The mouse over events work but when you click on one of the images it does nothing.

Ive used the following protection script.

<!– 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>

    <!– STEP TWO: Insert the onLoad event handler into your BODY tag –>

    <BODY OnLoad=”trap()”>

    <p><center>
    <font face=”arial, helvetica” size=”-2″>Free JavaScripts provided<br>
    by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
    </center><p>

    <!– Script Size: 0.81 KB –>

    It apears that the script has taken over the left as well as the right hand clicks.

    Can any one see how I can fix this?

    to post a comment
    JavaScript

    10 Comments(s)

    Copy linkTweet thisAlerts:
    @steelersfan88Sep 15.2004 — Wh ywould you use that? Anyone can still retrieve your image from the source code, by disabling javascript, accessing the temporary Internet files/cache, dragging the image to the desktop, saving the entire website, etc ...

    Watermark ... the onl way to add real copyrights to your picture.
    Copy linkTweet thisAlerts:
    @JPnycSep 15.2004 — onrightclick should be the event
    Copy linkTweet thisAlerts:
    @Jason_MoodieauthorSep 15.2004 — I thought the same. I have tried this but it did not work.
    Copy linkTweet thisAlerts:
    @Jason_MoodieauthorSep 15.2004 — I have found code that works.


    Place this in your head tag:

    <script language="javaScript">

    function right(evnt){

    if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null) {

    if (evnt.which >= 2){

    alert("We appreciate your support!");

    return false;

    }

    }else if (event.button>=2) alert("We appreciate your support.");

    }

    document.onmousedown = right;

    if (document.layers) window.captureEvents(Event.MOUSEDOWN);

    window.onmousedown=right;

    </script>

    Add this to your body tag:

    <body onContextMenu="alert('message');return false;">
    Copy linkTweet thisAlerts:
    @JonaSep 15.2004 — [font=trebuchet ms]Why try to protect the images? Anyone can press the Print Screen button and steal them, or get past the right-click. You're merely crippling the UI and frustrating users.[/font]
    Copy linkTweet thisAlerts:
    @Jason_MoodieauthorSep 15.2004 — Clients request. I agree. Customer is always right. Its more a deterrent than anything.

    Thanks for your help guys.
    Copy linkTweet thisAlerts:
    @Willy_DuittSep 15.2004 — That snippet will not work at all on Mozilla based browsers and will only somewhat work on Internet Explorer... And using IE, there are so many ways around that it is laughable... The least of is the Image Toolbar...

    You have gotten nowhere fast, and are spinning wheels attempting to do something that can not be done and your client is an idiot...

    Let me guess... the client also requested a fullsize window, numerous popups, followed by twice as many alerts and blinking text, flashing borders, and a dozen slideshows all working at the same time. Oh, lets not forget the javascript based menu which is completely inaccessible to those with javascript disabled...

    Is there no shame!!! ?

    .....Willy
    Copy linkTweet thisAlerts:
    @Jason_MoodieauthorSep 15.2004 — Works in Mozilla, as stated before as you can not obvously read, it is a prevention not a cure.

    Good Day.
    Copy linkTweet thisAlerts:
    @Willy_DuittSep 15.2004 — It doesn't work in my flavor of Mozilla... and this idea of [i]prevention[/i] is akin to holding two aspirins tightly between your knees as a form of birth control...

    However, my point is, a responsible developer would not bow to the idiotic whims of a client... He would educate the client that ONE: what he is wishing to do is fundementaly wrong; TWO: will more than likely anger his visitors and drive them away; THREE: will make his site inaccessible and FOUR: depending upon the country is illegal and could be fined...

    But yes, I can read... and from what I've read, I doubt there is a client... Your first sentence said: "[i]stop people clicking on[/i] [b][b]my images[/b]"....



    Whose ever images they are.... It's all a waste of time... And this folly of prevention will cause more harm than good...



    Have many good days;

    ....Willy
    Copy linkTweet thisAlerts:
    @JonaSep 15.2004 — [font=trebuchet ms]In the case of retail, the customer is always right, but in the case of Web design, the client is always [b]ignorant.[/b] ? I would suggest that you explain to them why you are against protecting the images - or even trying to [/font]
    ×

    Success!

    Help @Jason_Moodie 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.17,
    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,
    )...