Home > Web Front-end > JS Tutorial > body text

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

一个新手
Release: 2017-09-21 10:28:37
Original
5004 people have browsed it

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>
Copy after login

2. Disable copying (Ctrl+C)


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

3. Prohibit saving as
Add code between

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>
Copy after login

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;
}
Copy after login

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!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template