Home > Web Front-end > JS Tutorial > Sample code for JavaScript prohibiting page operations_javascript tips

Sample code for JavaScript prohibiting page operations_javascript tips

WBOY
Release: 2016-05-16 17:08:44
Original
1114 people have browsed it

Simple JS prohibits page right-click menu - to avoid website information being stolen

Copy code The code is as follows:



Web page The prohibition of copying is mainly implemented through JavaScript.

ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty( )>
-------------------------------------------------- ---
JS to prevent copying
---------------------------------------- ----------

Copy code The code is as follows:

< SCRIPT language=JavaScript1.2>
function disableselect(e){
return false}
function reEnable(){return true
}
file://if IE4
document. onselectstart=new Function ("return false")
file://if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}



--------------------------------- --------------------------
Prevent downloading js
--------------- ----------------------------------------

--------------------------------- -------------------------- < script language="JavaScript">





CSS prohibits selection and copying

< style>
body{
-moz-user-select:none;
hutia:expression(this.onselectstart=function(){return(false)});

}

< /style>


Here is the content of the web page. Can you copy it?




Application example:




Copy code


The code is as follows:




    JS控制页面
   


 

  & Lt; input id = "txt1" type = "text" value = "Hello World!" OnClick = "GettxtSelect (EVENT)"/& GT;

& lt; e = "Copy The value in the text box "OnClick =" SetcopyContent (); ut (); " onblur="FillTxtByInput();" />

content









Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template