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

参考:

禁止选中、复制: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>
原文地址:https://www.cnblogs.com/handt/p/2800876.html