Results 1 to 6 of 6

Thread: silent left & right click for images only

  1. #1
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default silent left & right click for images only

    Can this be modified for images only? Thanks.


    Quote:
    Originally Posted by cr3ative
    This is quite possibly the most pointless script I've ever made
    It is only verified to work in Internet Explorer.


    Disable right and left click:
    <SCRIPT LANGUAGE="JavaScript1.1">
    function disable(mousebutton)
    {
    var message = "";
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3||e.which==1) {(message);return false;}}}
    if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.onclick=clickIE;document.oncontextmenu=clickIE;}

    return true;
    }
    document.onmousedown = disable;

    </SCRIPT>


    This damned messageboard's software puts random spacers in my script, even when its in CODE tags. If you see spaces in the script that are obviously incorrectly placed, remove them. Cheers.

    cr3ative
    http://www.dynamicdrive.com/forums/showthread.php?t=548

  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

    Quote Originally Posted by swimmyz View Post
    Quote:
    Quote Originally Posted by cr3ative
    This is quite possibly the most pointless script I've ever made
    It is only verified to work in Internet Explorer.
    You would do well to take that (bold) to heart. No amount of disabling junk in javascript will protect images or (in many browsers) even prevent the right click context menu which allows for direct linking and copying of images. Often these sorts of scripts can mess up your page, it is best to avoid them. Any truly valuable images shouldn't be posted in full resolution on the web. Even if they are, if someone copying them causes you legal harm, you may sue (via copyright law) as a last resort, with threat of suit as an incentive to force the party responsible to desist, or force their ISP to force them to desist.
    - John
    ________________________

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

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

    Default

    I realize all that. I'm a teacher and so would just like to do this with my students' pictures. Not everyone would know how to get them, just an extra safety measure for my students.

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Don't you just love the print screen button...

    BUT. I know what swimmyz means, most students don't even know that button exists, or any other method of capturing a picture.

    I think this would be simple enough:

    Code:
    <img src="whatever.jpg" oncontextmenu="return false;">
    - Mike

  5. #5
    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

    Quote Originally Posted by swimmyz View Post
    just an extra safety measure for my students.
    There is no extra safety in this. Any clever student can still copy the image(s), even relatively dull students who just happen to be using the FireFox browser (the first or second most used browser on the web, depending upon what statistics you believe) will have no trouble, its default configuration does not allow any javascript to override the context menu. Future versions of IE will probably follow suit.

    If you want your students to really learn about the web, you will be doing them a huge favor by never creating the illusion that content can be protected by client side code.
    - John
    ________________________

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

  6. #6
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks so much mburt! We're talking about 2nd graders here, so this will help. I really appreciate it-even if everyone else thinks it's crazy.

    Quote Originally Posted by mburt View Post
    Don't you just love the print screen button...

    BUT. I know what swimmyz means, most students don't even know that button exists, or any other method of capturing a picture.

    I think this would be simple enough:

    Code:
    <img src="whatever.jpg" oncontextmenu="return false;">

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
  •