禁止页面内选中、复制、鼠标右键的脚本

参考:

禁止选中、复制:http://support.microsoft.com/kb/318086

禁止鼠标右键   :http://www.javascriptsource.com/page-details/no-right-click-2.html

这里也有完整版:http://www.boogiejack.com/no_right_click.html

虽然参考文章很老,但脚本依然有效,亲测chrome/ie 8 有效。 (至于如何bypass,不在讨论范围内)

 

完整代码:

复制代码
 1 <script type="text/JavaScript">
 2 function killCopy(e){
 3     return false
 4 }
 5 function reEnable(){
 6     return true
 7 }
 8 document.onselectstart=new Function ("return false")
 9 if (window.sidebar){
10     document.onmousedown=killCopy
11     document.onclick=reEnable
12 }
13 var message="NoRightClicking";
14 function defeatIE() {if (document.all) {(message);return false;}}
15 function defeatNS(e) {
16     if(document.layers||(document.getElementById&&!document.all)) {
17         if (e.which==2||e.which==3) {
18             return false;
19         }
20     }
21 }
22 if (document.layers){
23     document.captureEvents(Event.MOUSEDOWN);document.onmousedown=defeatNS;
24 }else{
25     document.onmouseup=defeatNS;document.oncontextmenu=defeatIE;
26 }
27 document.oncontextmenu=new Function("return false")
28 </script>
复制代码

 

posted @   handt  阅读(226)  评论(0编辑  收藏  举报
编辑推荐:
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
阅读排行:
· C# 13 中的新增功能实操
· Ollama本地部署大模型总结
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(4)
· langchain0.3教程:从0到1打造一个智能聊天机器人
· 2025成都.NET开发者Connect圆满结束
点击右上角即可分享
微信分享提示