A-A+

不错的防止别人查看页面的代码

2017年05月31日 wordpress, 点滴记录 评论 5 条 阅读 4,835 次浏览 次
<!--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>

防偷源码

屏蔽Ctrl+S 保存 F12 右键

标签:

5 条留言  访客:0 条  博主:0 条

  1. QQ游客

    wordpress中,把上面面代码放到footer.php里即可

  2. 缙哥哥

    你自己没用上啊!

    • yezi

      没有 我这就是分享 没有必要禁止复制啊

  3. 缙哥哥

    经测试,Ctrl+s仍旧能保存!

    • yezi

      大概还不是那么完美

评论已关闭!

Copyright © 海边拾贝 保留所有权利.   Theme  Ality 鲁ICP备17020531号-1
网站已运行: | 耗时 0.475 秒 | 查询 57 次 | 内存 29.93 MB

用户登录