1. Disable right-click and copy
Method 1:
Add the following code to the webpage:
<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 <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.
Fang
Method 3:
If you only restrict replication, you can add the following code in <body>:
<Body oncopy = "alert ('Sorry, copying is prohibited! '); Return false; ">
2. Enable menu "TextInvalid part "-" Save"
If you only disable right-click and select copy, you can also use "file"-"Save as" in the browser menu to copy files. To copy
Bay failure. You can add the following code between <body> and </body>:
<Noscript>
<Iframe src = "*. htm"> </iframe>
</Noscript>
In this way, when a user saves a webpage, the error "the Web page cannot be saved" will occur.
------------------------------------
You can also use the event. preventDefault () method to prevent oncontextmenu () and onselectstart ()
Document. oncontextmenu = function (evt ){
Evt. preventDefault ();
}
Document. onselectstart = function (evt ){
Evt. preventDefault ();
};
-------------------------------------
Since it can be disabled, you can also enable it and assign a value to the event again. You can assign a value to null or a string or Boolean value. For example:
Document. oncontextmenu = "";
Document. onselectstart = true;
Or disable js: Open Google's browser, select "Settings", select "privacy settings", select "content settings", select "JavaScript", and select "do not allow any website to run JavaScript ", refresh the settings.