防止网页被审查元素JS代码,可以防止一般用户在网页上审查元素
; m$ D+ z4 z) _- C- <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>
复制代码 5 Z$ l: Q$ }5 X: _& q, W
|
|