Do you have any web text or pictures that you have encountered in your life or work that you can't copy and paste? When I first started working, I thought my computer was broken. That's ridiculous! Forgive me for my ignorance.
So today to share with you about how to use JS code to prohibit the site content is copied, pasted, save as. Have the necessary small partners to learn by themselves.
650) this.width=650; "class=" AlignCenter size-full wp-image-276 "src=" http://www.aliyue.net/wp-content/uploads/2016 /02/1.png "alt=" 1 "width=" "height=" "style=" height:auto;vertical-align:middle;border:0px;text-align:center; margin:0px auto; "/>
First, right-click and copy invalidation
Method 1: Add a bit of code to the Web page:
<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 the following: <body oncontextmenu= " Event.returnvalue=false "onselectstart=" Event.returnvalue=false ">
Method 3: If you only restrict replication, you can add the following code:
<body oncopy= "alert (' Sorry, no copying! '); return false; " >
Second, 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. In order to invalidate the copy, the following code can be added between <body> and </body>:
<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 ()
Document.oncontextmenu=function (evt) {Evt.preventdefault ();} document.onselectstart=function (evt) {Evt.preventDef Ault (); };
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:
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", Set the refresh to complete.
===============================
Javascript
================================
This article is from the "Xiao Yue Blog" blog, please be sure to keep this source http://aliyue.blog.51cto.com/11564403/1782500
Website content is forbidden to copy and paste, save as JS code