updated/improved code
OK, some of the issues raised here were 1) Javascript disabling 2) Opera browser 3) 3-button mice 4) Using the no-script code in a pop-up window
Keep in mind that all of this is NOT intended to be foolproof. This is only meant to discourage the casual thief or those that don't understand that taking the images are actually stealing if they aren't selling it. As David pointed out, saving a screen shot and editing out the photo is still an option. Again, this is only a deterrent, not a fool-proof preventative measure. I hope everybody actually reads this before posting ;-)
For users that diable javascript, add this code between the <head> tags in your code:
<noscript>
<meta http-equiv="refresh" content="0; URL=../browserError.htm">
</noscript>
This will take them to another page that you designate if they have javascript disabled. Of course, a user can still disable meta refresh in their browser, but again, this is only a deterrent! ;-)
To allow only IE and Firefox browsers and specifically block Opera browsers as well as accomodate mice with 3 buttons, use this code here:
<script>
msg="Nasty message goes here";
if ((navigator.userAgent.indexOf("Opera")== -1) && (navigator.userAgent.indexOf("MSIE")!= -1) || (navigator.userAgent.indexOf("Firefox")!= -1)) {
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(msg);return false");
}else{
window.document.location.href = "../browserError.htm";
}
</script>
Now, you can save the javascript code above as a file and call it something like "noclick.js" and be sure to remove the<script></script> before doing so. Then, call the code in your webpage with this line:
<SCRIPT SRC="../noclick.js"></SCRIPT>
I'm using this in my pop-up windows that contain the larger pic. Here are two lines of code that will help you do that if you have saved the no-click described above:
win = window.open("", menubar='no', toolbar='no');
win.document.write("<html><SCRIPT SRC='../noclick.js'></SCRIPT><body><img src=01.JPG></body></html>");
I hope this helps reduce some of the swiping of photos out there. I also believe that by doing this and somebody still steals your photos and uses it for profit, you'll have an easier time proving their malicious attempt by showing you employed considerable effort to prevent copying of images. 8)