zoukankan      html  css  js  c++  java
  • 网页禁止右键查看源码屏蔽键盘事件

    <script type="text/javascript">
          window.onload = function(){
             //屏蔽键盘事件
               document.onkeydown = function (){
                   var e = window.event || arguments[0];
                   //F12
                    if(e.keyCode == 123){
                        return false;
                  //Ctrl+Shift+I
                    }else if((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)){
                       return false;
                  //Shift+F10
                 }else if((e.shiftKey) && (e.keyCode == 121)){
                        return false;
                    //Ctrl+U
                    }else if((e.ctrlKey) && (e.keyCode == 85)){
                        return false;
                    }
                };
               //屏蔽鼠标右键
              document.oncontextmenu = function (){
                    return false;
            }
            with(document.body) {
          oncontextmenu=function(){return false}
          ondragstart=function(){return false}
          onselectstart=function(){return false}
          onbeforecopy=function(){return false}
          onselect=function(){document.selection.empty()}
          oncopy=function(){document.selection.empty()}
        }
            }
     
     </script>
    作者:赖忠标
    免责声明:文章、笔记等仅供分享、探讨、参考等学习之用,因此造成的任何后果概不负责。(如有错误、疏忽等问题,欢迎指正、讨论,谢谢)
    本文版权归作者和博客园共有,欢迎转载,但请务必在文章页面明显位置给出原文连接,谢谢配合。
  • 相关阅读:
    13-Smell味道-调味料
    12-Juice饮料
    11-Snack小吃
    10-Meat肉类
    09-Fruit水果
    08-Vegetables蔬菜
    [svc]共享内存
    [sql]sql的select字符串切割
    [js] 渲染树构建、布局及绘制
    [js]变量提升-关于条件
  • 原文地址:https://www.cnblogs.com/lazb/p/15189314.html
Copyright © 2011-2022 走看看