Commonly used anti copy code for web pages

web front end fourteen thousand nine hundred and eighty-one 13 years ago (2011-03-04)


The best anti copy code 1: (Paste this code into the body to effectively prevent selection, anti copy and right mouse button)

 <script type="text/javascript">document.body.oncontextmenu=document.body.ondragstart= document.body.onselectstart=document.body.onbeforecopy=function(){return false;}; document.body.onselect=document.body.oncopy=document.body.onmouseup=function(){document.selection.empty();};</ script>

The best anti copy code 2: (Paste this code into the body to effectively prevent selection, anti copy and right mouse button)

 <script language="JavaScript"> document.oncontextmenu=new Function("event.returnValue=false;"); document.onselectstart=new Function("event.returnValue=false;"); </script>

It is forbidden to view the source file code of the web page. Just insert the web page.

 <body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()"> <noscript><iframe src="/blog/*>";</ iframe></noscript>

1. The right mouse button will be completely shielded

 oncontextmenu="window.event.returnvalue=false" <table border oncontextmenu=return (false)><td>no</table>//Available for Table

2. Cancel selection and prevent copying

 <body onselectstart="return false">

3. No pasting

 onpaste="return false"

4. Prevent replication

 oncopy="return false;" oncut="return false;"

5. Prevent being framed

 <SCRIPT LANGUAGE=javascript><!--  if (top.location != self.location)top.location=self.location;  // --></SCRIPT>

6. Web page cannot be saved as

 <noscript><iframe src="/blog/*.html>";</ iframe></noscript>

7. Changing the connection is the display of the status bar

 <a href=" "OnMo...; window. status='Inter the content displayed in the connection status bar&rsquo;; return true">

8. Prohibit target objects from being downloaded (such as pictures)

The following code will help you prevent the target objects in the web page from being downloaded:

 <a href="javascript: void (0)" onMouseDown="alert ('Sorry! Pictures can't be downloaded! ')"><img src="Picture address" alt=""/></a>

9. The page cannot be completely refreshed. It is better to use it in the window out of the pop. There is no toolbar

 <body onkeydown="KeyDown()" onbeforeunload="location=location"  oncontextmenu="event.returnValue=false"> <script language="Javascript"><!--   function KeyDown(){  if ((window.event.altKey)&&       ((window.event.keyCode==37)||    (window. event. keyCode==39) {alert ("Please visit my homepage")     event.returnValue=false;       }  If ((event. keyCode==8) | | (event. keyCode==116)) {//Block the F5 refresh key     event.keyCode=0;       event.returnValue=false;       }  If ((event. ctrlKey)&&(event. keyCode==78)) {//Shield Ctrl+n     event.returnValue=false;       }  If ((event. shiftKey)&&(event. keyCode==121)) {//Shield shift+F10     event.returnValue=false;       }   </script>  </body>