欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

网页源代码保护(禁止右键、复制、另存为、查看源文件)

程序员文章站 2022-04-22 19:42:53
...
1、禁止右键菜单


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

2、禁止复制(Ctrl+C)


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

3、禁止另存为
在<body></body>之间加入代码
<noscript><iframe src='*.htm'></iframe></noscript>
4、禁止缓存
禁止缓存 在页面中使用HTML标记,如下面:

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

5、禁止文字选中css代码

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

以上就是网页源代码保护(禁止右键、复制、另存为、查看源文件)的详细内容,更多请关注其它相关文章!