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

 

作者:非凡jk
來源:CSDN
原文:https://blog.csdn.net/jamesi987/article/details/78840802
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM