禁用鼠标右键和f12

Posted on 2021-02-03 17:04  猫头唔食鱼  阅读(108)  评论(0编辑  收藏  举报
    // 禁止右键
    window.oncontextmenu = function () {
        return false
    }
   
    // 禁止f12
    document.onkeydown=function (e){
        var currKey=0,evt=e||window.event;
        currKey=evt.keyCode||evt.which||evt.charCode;
        if (currKey == 123) {
            window.event.cancelBubble = true;
            window.event.returnValue = false;
        }
    }