Trap the right mouse clickTag(s): Language

<script language="javascript">
 function click(e) {
  if (navigator.appName == 'Netscape'
           && e.which == 3) {
      alert("no right click please")
      return false;
   else {
      if (navigator.appName == 'Microsoft Internet Explorer'
          && event.button==2)
         alert("no right click please")
         return false;
   return true;
No right mouse button here!
Here a way posted by A. Weslowski on the Real How-to mailng list.
<SCRIPT LANGUAGE="JavaScript1.2">
var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;
if (ns) document.captureEvents(Event.MOUSEDOWN || Event.CLICK);
document.onclick = sourcecodeprotect;
document.onmousedown = sourcecodeprotect;

// ***********************************************************
function sourcecodeprotect(e) {
  if (ns&&(e.which==3)) return false;
  else if (ie&&(window.event.button==2)) alert("Source code protected");
  else return true;

function cleanup() {
  if (ns) document.releaseEvents(Event.MOUSEDOWN || Event.CLICK);

<BODY onunload="cleanup()">
No right click here!
NOTE: You can still see the page source via the browser menu but you can make it a little harder by opening a new window without the menu bar or use a Frameset to display your page PLUS the above snippets to trap the RMB.

Some browsers may support a special parameter in the BODY tag to disable the RMB

<BODY oncontextmenu="return false">
To disable the Disable Mouse Dragging (Highlighting)
<BODY ondragstart="return false">
To disable the SELECT/COPY
<BODY onselectstart="return false">

blog comments powered by Disqus