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

moqu8 2020-6-30

1980 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
新站优化中!部分功能尚未完善,敬请谅解!
支持中心