终极解决浏览器禁用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;
                    }
                };

        var threshold = 160; // 打开控制台的宽或高阈值
        // 每秒检查一次
        window.setInterval(function () {
            if (
                window.outerWidth - window.innerWidth > threshold ||
                window.outerHeight - window.innerHeight > threshold
            ) {
                window.location.href = "https://i.cnblogs.com/";
            }
        }, 1e3);
posted @ 2021-12-08 15:55  好命先生w  阅读(1373)  评论(0)    收藏  举报