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

作者:PB模板网 发布时间:2020-12-15 浏览量:3084 次 点赞量:449 次

收集些通过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) {
        return false;
    }
};

2、禁止浏览器默认右键菜单操作

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

3、监听键盘F12键操作

document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if (e && e.keyCode == 123) {
        e.returnValue = false;
        return (false);
    }
}

以上方式对于大部分浏览器适用,不过也不是万能,具体以实际使用为主。

感谢您的支持与鼓励

您的支持是我持续二开与分享的动力!

微信支付 微信支付
支付宝支付 支付宝
账号登录
免费注册
忘记密码?
💬

微信扫码咨询

微信二维码
🐧

在线客服

⏰ 工作时间: 09:00 - 18:00

👥

建站交流群

群号: 787980028