1. 首页>>建站/教程

网站禁止F12键和右键操作的方法

收集些通过JS禁止页面F12键和右键操作控制台

1607999000544682.png

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);
    }
}

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


文章标题:网站禁止F12键和右键操作的方法

文章链接:https://www.symiyun.com/muban/58.html

版权说明: (www.symiyun.com) 所发布的内容,部分为原创文章,转载请注明来源,网络转载文章如有侵权请联系我们! 某些文章具有时效性,若有错误或已失效,请联系客服:1107710272@qq.com

联系我们

在线咨询:点击这里给我发消息

微信号:18772768263

工作日:9:30-18:30,节假日休息