javascript实现禁止右键和F12查看源代码

 <!DOCTYPE HTML>
 <html lang="en-US">
 <head>
     <meta charset="UTF-8">
     <title></title>
 </head>
 <body>
     测试demo
 </body>
 <script type="text/javascript">
     document.onselectstart=new Function("event.returnValue=false");//禁止选中(无法复制)
     //document.oncontextmenu=new Function("event.returnValue=false");//取消鼠标右键

 function click(e){
     if (document.all){
         if (event.button==2||event.button==3) { alert("欢迎光临!");
         oncontextmenu='return false';
         }
     }
     if (document.layers){
         if (e.which == 3) {
         oncontextmenu='return false';
         }
     }
 }

 if(document.layers){
     document.captureEvents(Event.MOUSEDOWN);
 }

 document.onmousedown=click;
 document.oncontextmenu = new Function("return false;")
 document.onkeydown =document.onkeyup = document.onkeypress=function(){
     if(window.event.keyCode == 123){
         window.event.returnValue=false;
         return(false);
     }
 }
 </script>
 </html>
上一篇:Oracle数据类型与.NET中的对应关系


下一篇:python 设计模式之桥接模式 Bridge Pattern