Take a note
The code copy is as follows:
// Disable the 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 (if you write the following CSS, this code is not required, the new version of the browser supports it)
$(function() {
$("body").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 JavaScript from failing after disabling it, it can be written in CSS (supported by the new browser and gradually became the standard):
The code copy is as follows:
body {
-moz-user-select:none; /* Firefox private attribute*/
-webkit-user-select:none; /* WebKit kernel private attributes*/
-ms-user-select:none; /* IE private attributes (IE10 and later) */
-khtml-user-select:none; /* KHTML kernel private attributes*/
-o-user-select:none; /* Opera private attribute*/
user-select:none; /* CSS3 attribute*/
}
The code is very simple, but the implementation functions are very practical. However, it should be noted that prohibiting copying on this free Internet is not a very worthy of promotion. Please be practical according to the situation.