+ Reply to Thread
Results 1 to 3 of 3

Thread: right click JavaScript

  1. #1
    rolandr is offline x10Hosting Member rolandr is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    70

    right click JavaScript

    I found a useful JavaScript for website when you right click, an alert message pops up. This prevent the viewer from copying images on your website. Of course there's ways around it.

    I know many of you this script isn't anything new but this script works in MS Internet Explorer but not in my Mozilla Fire Fox.

    Here's the script. I kept the source from where I got it intact because its good practice to state your source.

    /*
    Thank you for choosing Java-scripts.net
    as your javascript resource site. Below
    is the free javascript code that you requested
    along with installation instructions. We
    look forward to seeing you again at
    http://www.java-scripts.net
    ===============================

    Script Details
    Title: No Right Click
    Description: Disable right clicking on your site to prevent people from stealing your images and code!
    ===============================

    Copy the following code into your HEAD tags.
    ===============================


    No rightclick script v.2.5
    (c) 1998 barts1000
    barts1000@aol.com
    Don't delete this header!
    */

    var message="\nImages are property of RR\nImages and Text protected!\nALL RIGHTS RESERVED";

    // Don't edit below!

    function click(e) {
    if (document.all) {
    if (event.button == 2) {
    alert(message);
    return false;
    }
    } if (document.layers) {
    if (e.which == 3) {
    alert(message);
    return false;
    }
    }
    }
    if (document.layers) { document.captureEvents(Event.MOUSEDOWN); }
    document.onmousedown=click;


    Does anyone know the JavaScript that works both in IE and FireFox?

  2. #2
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: right click JavaScript

    I recommend you DON'T use such scripts at all -- they are simply irritating, and switching javascript off removes all protection (By default I don't run JS on any sites, so this "protection" wouldn't work for me...). If it is images you are protecting, then any user can get the image files directly from their cache folder if they want, even if JS is active.

    If you insist on using such a script (and want to irritate users) then here is a script claiming to "support" FF as well as IE.

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: right click JavaScript

    It's fairly easy to have such scripts target only images by registering the handler on images (accessible via document.images) rather than the entire document. This won't provide any more protection, but will greatly reduce annoyance. Another option is to position a transparent image on top of each image you wish to protect. Yet another option is to watermark the image.

    To prevent caching in IE, you can send "Cache-control: no-cache", "Expires: -1" and "Pragma: no-cache" headers, though even this won't be enough to prevent someone from d/ling an image.

    The most reliable solution is not to put hi-res pictures online.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Earn Money Online
    By nbkt231092 in forum Earning Money
    Replies: 0
    Last Post: 08-28-2009, 01:52 AM
  2. Vmware Workstation NAT problem on Windows 7
    By vnpadkids in forum Computers & Technology
    Replies: 0
    Last Post: 07-27-2009, 12:51 AM
  3. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  4. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  5. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers