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

Sample code for JavaScript prohibiting page operations_javascript tips

WBOY
WBOYOriginal
2016-05-16 17:08:441080browse

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









Statement:
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
Previous article:extjs4 treepanel dynamically changes row height example_extjsNext article:extjs4 treepanel dynamically changes row height example_extjs

Related articles

See more