One, the right mouse button is prohibited menu:
There are two ways to disable the right mouse button
1, add the JavaScript event handle in the body tag of the HTML element, the code is as follows:
Copy Code code as follows:
<body oncontextmenu= "return false" >
Note: You can also prohibit the right button in the location specified in the Web page. For example, you just want to ban a page in a picture on the right to download, or you just want to be in the page of a text or a table on the right button, you also need to add such as the red code to the corresponding HTML tag elements, for example:
Copy Code code as follows:
<!--added to the picture-->
<table oncontextmenu= "return false" >
<!--added to the table-->
<font oncontextmenu= "return false" > text content </font>
<!--added to the text-->
2, write a JavaScript function, and then invoke event processing, the code is as follows:
Copy Code code as follows:
<script language=javascript>
<!--
Document.oncontextmenu=mylock1;
function Mylock1 () {
Event.returnvalue=false;
}
-->
</script>
Note: Please pay attention to the code case! Copy the above code to the HTML source code of the Web page between
If you want to right-click on the label specified by the page element, simply change the document to the corresponding Page object tag name.
No drag to select page elements:
As with the previous example, there are two ways to prevent the right mouse button
1, add the JavaScript event handle in the body tag of the HTML element, the code is as follows:
Copy Code code as follows:
<body onselectstart= "return false" >
Description: Similar to the above prohibited right key usage
2, write a JavaScript function, and then invoke event processing, the code is as follows:
Copy Code code as follows:
<script language=javascript>
<!--
Document.onselectstart=mylock1;
function Mylock1 () {
Event.returnvalue=false;
}
-->
</script>
Note: Please pay attention to the case of the statement! Copy the above code to the HTML source code of the Web page between
If you want to right-click on the label specified by the page element, simply change the document to the corresponding Page object tag name.
To sum up, if we both prohibit the Web page right-click menu, but also prohibited mouse drag, that is, you can use the following two methods:
Method One:
Copy Code code as follows:
<body oncontextmenu= "return false;" onselectstart= "return false" >
Method Two:
Copy Code code as follows:
<script language=javascript>
<!--
Document.onselectstart=mylock1;
Document.oncontextmenu=mylock1;
function Mylock1 () {
Event.returnvalue=false;
}
-->
</script>
These are my common methods of summary, not very comprehensive, small partners have other methods also please give me a message, this article continues to update.