JS 禁止F12和右键操作控制台

1.鼠标点击事件

document.onmousedown = function mdClick(event) {
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if (e.button == 2 || e.button == 3) {
        mAlert();
    }
}

 2. 禁用浏览器 默认右键菜单

document.oncontextmenu = new Function("return false;");

 3.监听键盘事件

document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
    var e = event || window.event || arguments.callee.caller.arguments[0];

    if (e && e.keyCode == 123) {
            mAlert();
            e.returnValue = false;
            return (false);
    }
}
function mAlert() {
    alert("禁止操作控制台");
}

 

作者:非凡jk
来源:CSDN
原文:https://blog.csdn.net/jamesi987/article/details/78840802
版权声明:本文为博主原创文章,转载请附上博文链接!

 

posted @ 2018-12-03 14:17  橙云生  阅读(4753)  评论(0编辑  收藏  举报