There are several EcmaScript snippets floating around to disable the context menu of web browsers that run on the Windows and UNIX systems. (EcmaScript is the language formerly known as JavaScript.) Web designers who use such scripts to "protect" their content are doing more harm than good.
If you want to protect your images without getting in the way of navigation, use this snippet and only this snippet freely available from The JavaScript Source:
<script language="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source! http://javascript.internet.com/ --> <!-- Toss this part between <head> and </head> --> <!-- Begin function right(e) { var msg = "Use the Print Screen key instead."; if ((navigator.appName == 'Netscape' && e.which == 3) || (navigator.appName == 'Microsoft Internet Explorer' && event.button==2)) { alert(msg); return false; } else return true; } function trap() { if(document.images) for(i=0; i<document.images.length;i++) document.images[i].onmousedown = right; } // End --> </script>
Make sure to load it in the body tag: <body onLoad="trap()" bgcolor...>
Shame on these sites for using right-click traps.: http://pineight.8m.com/shitlist.htm#list
There are other ways to get around various "you can't right-click here" browser traps:
Both of these alternatives are better than doing a screen capture, because that will be "lossy."
telnet l33t.com 80 GET /pr0n/js_page.asp HTTP/1.0
HTTP options: --http-user=USER set http user to USER. --http-passwd=PASS set http password to PASS. --header=STRING insert STRING among the headers. -U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION. Recursive retrieval: -r, --recursive recursive web-suck -- use with care!. -l, --level=NUMBER maximum recursion depth (0 to unlimit). -m, --mirror turn on options suitable for mirroring.
Addition: If you are a Mac user you can drag a image which is no link out of the browser' s window, and drag it in in one task. Now the image will appear alone on the page, and you can save it via File->Save. novalis mentioned this to me.
Right-click traps are really lame because they inconvenience good people, and they do not stop bad people. Think of this: do you really give a damn if someone grabs one of your images and uses it as a background ? In which way does this damage you ? And again: the "professional" image thief will have an arsenal of tools that will tear through your puny JavaScript like a tank through a strawberry field.
Images can be sucked off a website with any number of non-interactive web clients, like wget. They take residence in the user's cache. And JavaScript can (luckily) be turned off. Sure, you can make JavaScript mandatory for browsing your site (and you can force users to run Explorer: in which case, bye bye Linux users), but are you sure you have enough unique, compelling, precious content that users will put up with the inconvenience ? Remember, this is still a browser's market, in other words there is an abundance of sites and a scarcity of eyeballs. And sites that really have content somewhat seem to ignore the issue. Right-click trapping appears to be an obsession of budding graphic designers and photographers fresh out the egg, terrified that someone will steal their images. I understand that that can be a concern, but right-click trap is not the solution.
No right-click scripts are an attempt to keep people from "stealing" web content. They are ineffective, as they are easily worked around, but people use them anyway. They are an abuse of Javascript; if you were planning on using them, PLEASE DON'T.
Of course, the only reason these scripts work at all is because of poor thinking in browser design. Javascript should never be able to override context menus, and if for some reaons it would be cosmetic to do so, this should be overridable, for instance with a ctrl + right-click.
With the release of Internet Explorer 5 and also Netscape 6.1, the no-right-click scripters have a new event to strike fear into the hearts of Internet users everywhere: document.oncontextmenu.
Whereas traditional right-click scripts captured document.onmousedown and .onmouseup, which can be circumvented by holding down clever combinations of mouse buttons to confuse the browser, or by pressing the Windows key, this event is specifically tailored to control the context menu.
Like any technology, it has its good uses -- for instance, writing your own context menu in a web application that is more relevant to the task at hand -- and its bad uses. Try inserting this small section of JavaScript into a web page:
Luckily, most no-right-click scripts as yet have yet to be updated to support the new browsers and are therefore able to be circumvented. Thank goodness for antiquated reference materials...
Another way of avoiding this plague, aside from the excellent wget or just pasting the image URL into your location bar, is to simply disable JavaScript in your browser options. This should only be done as a temporary measure -- many sites require or recommend JS for navigation or operation, such as the E2 Source Code Formatter.
Enter Mozilla, designed for the convenience of you the user, not as a free giveaway aimed at selling your gaze to advertizers. Here are two ways to here's how to extract images from your browser cache without a right-click. Both worked in Mozilla 1.1 to 1.3 on Windows XP.
Method 1: Page properties.
Some web authors, in an effort to maintain control of their intellectual property, use bits of scripting to keep visitors from right clicking various parts of their web pages. The idea is to keep visitors from using their context menu to save or copy something.