This article describes how to prohibit the copying of webpage content using javascript. if you need it, take a note.
The code is as follows:
// Disable right-click menu, copy, and select
$ (Document). bind ("contextmenu copy selectstart", function (){
Return false;
});
// Disable Ctrl + C and Ctrl + V (supported by all browsers)
$ (Document). keydown (function (e ){
If (e. ctrlKey & (e. keyCode = 65 | e. keyCode = 67 )){
Return false;
}
});
// Set CSS to prohibit selection (this code is not required if the following CSS is written, which is supported by the new browser)
$ (Function (){
$ ("Body" detail .css ({
"-Moz-user-select": "none ",
"-Webkit-user-select": "none ",
"-Ms-user-select": "none ",
"-Khtml-user-select": "none ",
"-O-user-select": "none ",
"User-select": "none"
});
});
To prevent invalid JavaScript code after it is disabled, you can write it in CSS (supported by the new browser and gradually becomes a standard ):
The code is as follows:
Body {
-Moz-user-select: none;/* Firefox Private attribute */
-Webkit-user-select: none;/* Private attributes of the WebKit kernel */
-Ms-user-select: none;/* Private IE attributes (IE10 and later )*/
-Khtml-user-select: none;/* private attribute of the KHTML kernel */
-O-user-select: none;/* Opera private attribute */
User-select: none;/* CSS3 attribute */
}
The code is very simple, but the implementation function is very practical, but it should be noted that in this free internet, it is not worth promoting to prohibit replication. it is practical for everyone.