Use the oncontextmenu event list to disable the right-click menu
onconTextmenu==false; the right-click menu is disabled, and copying can be disabled using this.
Add attribute code to <body>:
οncοntextmenu="return false"
onselectstart="return false"
οncοpy="return false"
Prevent users from saving web pages:
Using the <noscript><iframe src=*.html></iframe></noscript> tag can prevent the web page from being saved directly, but it cannot prevent the web page from being downloaded by people using tools.
* is a wildcard.
Example 1:
<html>
<head>
<title>OnContextMenu Event</title>
<script language="JavaScript">
<!--
function uFunction()
{ ='You pressed the right mouse button, but the right-click menu cannot be displayed! ';}
function uFunction2()
{ ='You have pressed Ctrl+right mouse button to display the right-click menu. ';}
//-->
</script>
</head>
<body οncοntextmenu="if(!){uFunction();return false}else{uFunction2()}">
<div > You pressed the right mouse button, but the right-click menu cannot be displayed! <br>You have pressed Ctrl+right mouse button to display the right-click menu.
</div></body>
</html>
Example 2:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>useOnMousedownandOnContextmenuAdd left, center, right-click to the table</title>
<script type="text/javascript">
//
var keyArray = new Array(
new Array(0, "Right-click"),
new Array(1, "Left button"),
new Array(2, "Right-click"), // The right-click in IE7 is 2, and the official version of Maxthon 2.0 is 0. new Array(3, "Left and Right Key Press"),//In IE7, I cannot test capture, please use it with caution new Array(4, "Middle Key")
//More representation of the test by pressing two keys at the same time //new Array(6, "Right-click the middle button and press it at the same time"));
function Click()
{
var message = GetKeyMessage();
alert(message);
if ( == 2 || == 0) //Right-click,// The right-click in IE7 is 2, and the official version of Maxthon 2.0 is 0. {
//Processing code }
}
function GetKeyMessage(button)
{
for (var i = 0; i < ; i++)
{
if (keyArray[i][0] == button)
{
return keyArray[i][1] + ", = " + button;
}
}
return "Unknown key combination, = " + button;
}
</script>
</head><body>
<table cellpadding="0" cellspacing="0" border="1">
<tr>
<!--οncοntextmenu="return false"Block shortcut menu-->
<td οncοntextmenu="return false" οnmοusedοwn="Click()">Please use the left button separately、Right-click、Middle key、左键Right-click组合点这里测试</td>
</tr>
<tr> <td>This form is not processed,Click here to no response</td> </tr> </table> </body>
</html>