1. Disable right-click and copy
Method 1:
Add the following code to the Web page:
Copy the code code as follows:
<script language= "Javascript" >
document.oncontextmenu=new Function ("Event.returnvalue=false");
document.onselectstart=new Function ("Event.returnvalue=false");
</script>
Method 2:
Add the following code to the <body>:
<body oncontextmenu= "return false" onselectstart= "return false" >
Or
<body oncontextmenu= "Event.returnvalue=false" onselectstart= "Event.returnvalue=false" >
In essence, Method 2 is the same as Method 1.
Method 3:
If you only restrict replication, you can add the following code to <body>:
<body oncopy= "alert (' Sorry, no copying! '); return false; " >
2. Make the menu "file"-"Save As" invalid
If you just disable right-click and select Copy, others can also copy files from the "file"-"Save as" button in the browser menu. To make the copy
The following code can be added between <body> and </body>:
Copy the code code as follows:
<noscript>
<iframe src= "*.htm" ></iframe>
</noscript>
This causes the "Unable to save web page" error to appear when the user saves the page.
Alternatively, you can use the Event.preventdefault () method to block OnContextMenu () and onselectstart ()
Copy the code code as follows:
document.oncontextmenu=function (evt) {
Evt.preventdefault ();
}
document.onselectstart=function (evt) {
Evt.preventdefault ();
};
Since you can disable it, you can also enable it, reassign the event to a value that can be assigned to null, or a string or Boolean value. Such as:
Copy the code code as follows:
document.oncontextmenu= "";
document.onselectstart=true;
or disable JS: Open Google Chrome, select "Settings" – Select "Privacy Settings" – Option "Content Settings" – select "JavaScript" – select "Do not allow any Web site to run JavaScript" and set the refresh to complete.
Website content JS settings prohibit copying, prohibit selection