禁用f12调试

window.onkeydown = window.onkeyup = window.onkeypress = function (event) {
// 判断是否按下F12,F12键码为123
if (event.keyCode === 123) {
event.preventDefault(); // 阻止默认事件行为
window.event.returnValue = false;
}
}
// 为右键添加自定义事件,可以禁用
window.oncontextmenu = function() {
event.preventDefault(); // 阻止默认事件行为
return false;
}
var threshold = 160; // 打开控制台的宽或高阈值
// 每秒检查一次
setInternet(function() {
if (window.outerWidth - window.innerWidth > threshold || window.outerHeight - window.innerHeight > threshold) {
// 如果打开控制台,则刷新页面
window.location.reload();
}
}, 1e3);

posted @ 2020-04-16 10:49  ZhenV5  阅读(423)  评论(0)    收藏  举报