不错的防止别人查看页面的代码,用来保护网站版权

时间:2016-7-10    作者:晨曦    分类:


防偷源码

屏蔽Ctrl+S 保存 F12 右键

<!--onselectstart:禁止选中 oncontextmenu:右键弹出版权 event.keyCode==27:按esc键表示放弃Esc键阻止网页继续载入,也就是说你按ESC键网页还是继续加载-->
<body onselectstart="return false;" oncontextmenu="alert('乐意数据提示:请尊重本网站版权!');return false;" onkeydown="if(event.keyCode==27) return false;">
<script type="text/javascript">
document.onmousedown = click;  //绑定禁用鼠标右键事件
document.onkeydown = ctrl_key; //绑定禁用键盘事件
function click() {
if (event.button == 2)      //单击的鼠标键为右键
{
alert('乐意数据提示:请尊重本网站版权!');
return false;
}
}
function ctrl_key() {
if (event.keyCode == 17) {                          //禁用CTRL+S 保存网页代码
window.alert("请尊重本网站版权!");
return false;
}
 
if (event.keyCode == 123) {                         //禁用F12查看源代码
alert('请尊重本网站版权!');
return false;
}
}
</script>

评论:

喜哥 2016-08-30 07:02
然而并没屁用。chrome 一个 view-source:http://qqleyi.com/?post=476 看光光。
晨曦 2016-09-11 05:55
@喜哥:哎,都说了简单防小白嘛