禁止保存,拖拽图片,禁用右键和F12

// 禁止保存,拖拽图片
    var imgs = $("img");
    imgs.on("contextmenu", function() {
        return false;
    });
    imgs.on("dragstart", function() {
        return false;
    });
    // 禁止非开发人员打开控制台和查看元素,在href上添加?debug可打开
    var windowHref = window.location.href;
    //右键
    $(document).on("contextmenu", function(event) {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (e.button == 2 && windowHref.indexOf('debug') == -1) {
            return false;
        } else {
            console.log(e.button)
        }
    });
    //f12
    document.onkeydown = function(e) {
        var currKey = 0,
            evt = e || window.event;
        currKey = evt.keyCode || evt.which || evt.charCode;
        if (currKey == 123 && windowHref.indexOf('debug') == -1) {
            return false
        } else {
            console.log(currKey)
        }
    }

 

posted @ 2020-07-22 18:16  justsilky  阅读(271)  评论(0编辑  收藏  举报