防止网页被审查元素JS代码 [复制链接]

moqu8 2020-6-30

2049 0
防止网页被审查元素JS代码,可以防止一般用户在网页上审查元素

<script type="text/javascript">
window.onkeydown = window.onkeyup = window.onkeypress = function (event) {
// 判断是否按下F12,F12键码为123
if (event.keyCode == 123) {
event.preventDefault(); // 阻止默认事件行为
window.event.returnValue = false;
}
}

var threshold = 160; // 打开控制台的宽或高阈值
// 每秒检查一次
window.setInterval(function() {
if (window.outerWidth - window.innerWidth > threshold ||
window.outerHeight - window.innerHeight > threshold) {
// 如果打开控制台,则刷新页面
window.location.reload();
}
}, 1e3);
</script>
<script type="text/javascript">
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) { alert("魔趣建站禁止操作");
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
document.onkeydown =document.onkeyup = document.onkeypress=function(){
if(window.event.keyCode == 123) {
window.event.returnValue=false;
return(false);
}
}
</script>



最新回复 (0)
返回
支持中心
邮箱:winkill2012@qqcom

历史资源已不再提供任何技术支持和售后服务,客服仅处理无法下载或支付相关问题,资源使用或异常问题请自行解决!
支持中心