Home  >  Article  >  Web Front-end  >  Web page source code protection (right-clicking, copying, saving as, and viewing source files are prohibited)

Web page source code protection (right-clicking, copying, saving as, and viewing source files are prohibited)

一个新手
一个新手Original
2017-09-21 10:28:374933browse

1. Disable right-click menu


<script type="text/javascript" language="javascript">
function noMenuTwo(){
     if(event.button == 2){
           alert(&#39;禁止右键菜单!&#39;);
           return false;
     }
}
document.onmousedown = noMenuTwo;
//或者
<p oncontextmenu="return false"></p>
</script>

2. Disable copying (Ctrl+C)


<script type="text/javascript" language="javascript">
function noCopy(){
     alert("禁止使用Ctrl+C进行复制操作!");
     event.returnValue = false;
}
</script>
//<body oncopy = "noCopy()">

3. Prohibit saving as
Add code between 6c04bd5ca3fcae76e30b72ad730ca86d36cc49f0c466276486e50c850b7e4956
2b0b25ff593c5b6c03403dd6234ffb2c< ;iframe src='*.htm'>065276f04003e4622c4fe6b64f465b88f920f363442462683100636cb2662870
4. Disable caching
Disable caching by using HTML tags in the page, as follows:

<HEAD>
     <META http-equiv=Pragma content=no-cache>
     <META http-equiv=Cache-Control content=no-cache>
     <META http-equiv=Expires content=0>
</HEAD>

5. Prohibit text from selecting css code

body{
	-o-user-select:none;
	-ms-user-select:none;
	-webkit-user-select:none;
	-moz-user-select:none;
	user-select:none;
}

The above is the detailed content of Web page source code protection (right-clicking, copying, saving as, and viewing source files are prohibited). For more information, please follow other related articles on the PHP Chinese website!

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