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("禁止操作控制台");
}

 

转载自:https://www.cnblogs.com/chengyunshen/p/10058189.html

posted @ 2020-08-04 18:01  诩小贝  阅读(464)  评论(0编辑  收藏  举报
Copyright ©2016 诩小贝   联系QQ:980823367