Sunday, October 14, 2012

Turn Off the Right Click On the Browsers

Example #1: Turn Off the Shortcut Menu

  1. Open a new page in FrontPage.
  2. Switch to HTML view.
  3. Locate the opening <BODY> tag.
  4. Modify the <BODY> tag to resemble the following:
    <body onContextMenu="return false">
         
  5. Preview the page in Internet Explorer 5.0 or later. When you attempt to right-click anywhere on the page, the shortcut menu is not displayed.

Example #2: Use JavaScript to Display a Warning Message

  1. Open a new page in FrontPage.
  2. On the Insert menu, click Advanced.
  3. Select HTML.
  4. Type the following JavaScript code into the HTML Markup box:
    <script language="JavaScript">
    
    var message = "Sorry, that function is disabled.\n\n";
    message += "This page is copyrighted, and ";
    message += "all content is protected."; 
    
    function click(e) {
      if (document.all) {
        if (event.button == 2) {
          alert(message);
          return false;
        }
      }
      if (document.layers) {
        if (e.which == 3) {
          alert(message);
          return false;
        }
      }
    }
    
    if (document.layers) {
      document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=click;
    </script>
         
  5. Click OK.
  6. Preview the page in Internet Explorer 5.0 or later. When you attempt to right-click anywhere on the page, a message box appears, stating that the contents of the page are copyrighted, and therefore the right-click function is turned off (disabled).

No comments:

Post a Comment