JavaScript No Right-Click
This script is not that great, but for some, it does serve a purpose.
When it was new it was all the rage;
- A) because most people didn't know how to do it
- B) it had a certain "coolness factor" like most new things
That is not so now and more 'n more people have figured out how to get around it. Use it if you feel you must, but remember it is not as effective as it once was.
This script depends on a Browser look for and using, one of two things:
document.all in IE
document.layers in Netscape
Browsers that don't use either one (like any version of Mozilla or Netscape pre-version 4.x or versions 6.x+, will ignore this code altogether—which means it will not work. I have noticed though, this JavaScript code does work in some versions of IE 5.x, but not all.
Of course, if someone has JavaScript turned off, it's not going to work either, but you already knew that - didn't you.
<script type="text/javascript">
<!--
var ie4 = document.all;
var ns4 = document.layers;
if (ns4) document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = right;
function right(e) {
var msg = "Sorry, right-click has been disabled.";
if (ns4 && e.which == 3) {
alert(msg);
return false;
} else if (ie4 && event.button==2) {
alert(msg);
return false;
}
return true;
}
function trap() {
if (navigator.appName == 'Netscape' && document.images) {
for (i=0; i<document.images.length; i++)
document.images[i].onMOUSEDOWN = right;
}
}
// --></script>
</head>
Remember to add this: <body onLoad="trap();">
Instructions
Other than doing a Copy & Paste, there's not much else to do. Just remember that this script may stop "some people" from grabbing graphics or code, but not if they know how-to get around it!
Other Helpful Links
http://allmyfaqs.net/faq.pl?Hide_source