Right Button: Disabling

About This Product
FontsMadeEasy.com
 
Search This Database:
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet
Error processing SSI file

Question: Can I disable the Windows context menu that normally shows up when the user clicks the right mouse button?

Answer: In Netscape Navigator 4 or Internet Explorer 4 or newer browsers, you can disable the right-button menu. For example, it has been disabled on this page. If you use version 4 browser (or newer) under Windows, right-click anywhere on this page to verify that the menu is disabled indeed! (In older browsers, the context menu would still show up.)

To disable the right-button menu, insert the following code in your page's <HEAD> section:

<script language="JavaScript">
<!--
function mouseDown(e) {
 if (parseInt(navigator.appVersion)>3) {
  var clickType=1;
  if (navigator.appName=="Netscape") clickType=e.which;
  else clickType=event.button;
  if (clickType!=1) {
   alert ('Right mouse button is disabled.')
   return false;
  }
 }
 return true;
}
if (parseInt(navigator.appVersion)>3) {
 document.onmousedown = mouseDown;
 if (navigator.appName=="Netscape") 
  document.captureEvents(Event.MOUSEDOWN);
}
//-->
<script>

BackBack