杰克工作室 发表于 2023-2-25 10:45

禁止打开F12和禁止开发者模式,简单粗暴!

<pre>
&lt;script type=&quot;text/javascript&quot;&gt;

&nbsp; &nbsp;//禁用右键(防止右键查看源代码)&nbsp;
&nbsp; &nbsp;window.oncontextmenu=function(){return false;}&nbsp;

&nbsp; &nbsp;//禁止任何键盘敲击事件(防止F12和shift+ctrl+i调起开发者工具)&nbsp;
&nbsp; &nbsp;window.onkeydown = window.onkeyup = window.onkeypress = function () {&nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;window.event.returnValue = false;&nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;return false;&nbsp;
&nbsp; &nbsp;}

&nbsp; &nbsp;//如果用户在工具栏调起开发者工具,那么判断浏览器的可视高度和可视宽度是否有改变,如有改变则关闭本页面&nbsp;
&nbsp; &nbsp;var h = window.innerHeight,w=window.innerWidth;&nbsp;
&nbsp; &nbsp;window.onresize = function () {&nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;if (h!= window.innerHeight||w!=window.innerWidth){&nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; window.close();&nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; window.location = &quot;about:blank&quot;;&nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;}&nbsp;
&nbsp; &nbsp;}
&lt;/script&gt;
</pre>
对于懂一点的人来说,这一切都是徒劳。永远不可能实现绝对禁止,此方法只防小白。

杰克工作室 发表于 2024-3-4 21:15

我发现image.so.com在打开f12后,会自动跳转到debug模式,此时,鼠标基本是无法定位到页面元素的,而且是个死循环。想要得到图片,动作要快点。
<div style="background:#eeeeee; border:1px solid #cccccc; padding:5px 10px">//疯狂调试模式<br />
setInterval(function(){<br />
&nbsp;&nbsp; &nbsp;check();<br />
}, 2000);<br />
var check = function() {<br />
&nbsp;&nbsp; &nbsp;function doCheck(a) {<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if((&#39;&#39; + a /a)[&#39;length&#39;] !==1 || a % 20 ===0) {<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;(function() {}(&#39;debugger&#39;)());<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}else{<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;(function(){}[&#39;constructor&#39;](&#39;debugger&#39;)());<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;doCheck(++a);<br />
&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp; &nbsp;try{<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;doCheck(0);<br />
&nbsp;&nbsp; &nbsp;}catch(err){}<br />
};<br />
check();<br />
&nbsp;</div>
页: [1]
查看完整版本: 禁止打开F12和禁止开发者模式,简单粗暴!