PDA

View Full Version : silent left & right click for images only



swimmyz
08-03-2008, 08:22 PM
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

jscheuer1
08-03-2008, 08:31 PM
Quote:

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.

swimmyz
08-03-2008, 08:48 PM
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.

mburt
08-03-2008, 09:11 PM
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:


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

jscheuer1
08-03-2008, 11:40 PM
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.

swimmyz
09-06-2008, 02:09 AM
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.


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:


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