Example #1: Turn Off the Shortcut Menu
- Open a new page in FrontPage.
- Switch to HTML view.
- Locate the opening <BODY> tag.
- Modify the <BODY> tag to resemble the following:
<body onContextMenu="return false"> - 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
- Open a new page in FrontPage.
- On the Insert menu, click Advanced.
- Select HTML.
- 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> - Click OK.
- 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