I would like to disable right mouse button, but not on the entire page, but just on the image file <img src=””> to make an easy way for users not to write the image file on disk.
@konithomimoNov 29.2005 — #Once your page loads on a user's comp via their web browser all of your images are temporarily saved to their computer. Also, all the user has to do to get around no right clicking is to print page and then just go into photoshop or paint and just cut out the part that they want. basically this means that no right clicking is pointless.
@konithomimoNov 29.2005 — #<i> </i><script type="text/javascript"> var overImage=0;
function mouseDown(e) { var clickType=1; var tgt=""; if (parseInt(navigator.appVersion)>3) { if (navigator.appName=="Netscape") { clickType=e.which; tgt=""+e.target; if (tgt.length!=0 && tgt.charAt(tgt.length-1)=="#") overImage=1; } else { clickType=event.button; if (""+event.srcElement.className=="disabledMenu") overImage=1; } if (clickType!=1 && overImage) { alert ('Right-click menu is disabled for this image.') return false; } } return true; } if (parseInt(navigator.appVersion)>3) { document.onmousedown = mouseDown; if (navigator.appName=="Netscape") document.captureEvents(Event.MOUSEDOWN); } </script>
@felgallNov 29.2005 — #Decent web browsers don't allow the context menu to be disabled at all. Each Windows keyboard also comes with a key on the keyboard (immediately to the left of the right CTRL key) to bring up that menu even if the mouse button is disabled. The key on the keyboard is only disabled in older web browsers using oncontextmenu (while decent web browsers ignore all such attempts to interfere with their standard functions).
A transparent image in front of the one you want to protect will stop the context menu being able to be used to save the image while not interfering with the normal use of that menu. This works on all browsers but of course doesn't stop the images from being taken in any of dozens of other ways - see http://javascript.about.com/library/blimgprot.htm