[英]In Chrome DevTools How to prevent script from executing
I have a page not on my server, where a particular is running during page-loading 我的服务器上没有页面,页面加载期间正在运行该页面
...other stuff...
<script src="http://someserver.com/script.js"></script>
...other stuff...
and causing some problems. 并引起一些问题。
I need to debug this so first I'd like to prevent that script from loading. 我需要调试它,所以首先我想阻止该脚本加载。
How can I do this? 我怎样才能做到这一点? All I've found is that I can delete, edit or add a script after the page has loaded. 我发现的是,页面加载后可以删除,编辑或添加脚本。 But that is not what I need. 但这不是我所需要的。 I need to load the whole page but skip loading this very script. 我需要加载整个页面,但跳过加载此脚本。
Google Chrome can now do this for you. Google Chrome现在可以为您执行此操作。
Chrome will now block the request that loads that script. Chrome现在将阻止加载该脚本的请求。 To remove the block: 删除块:
There are a couple of approaches to this... the first being the old school way of handling ad blocking (which this is similar to), which is simply create a dns entry in your hosts file (C:\\windows\\system32\\drivers\\etc\\hosts on windows) and alias someserver.com to localhost 127.0.0.1: 有两种方法...第一种是处理广告拦截的老式方法(类似于),它只是在主机文件(C:\\ windows \\ system32 \\ drivers)中创建dns条目。 Windows上的\\ etc \\ hosts),并将someserver.com别名为localhost 127.0.0.1:
someserver.com 127.0.0.1
This, however, has the unfortunate side-effect of not loading ANYTHING from someserver.com. 但是,这有一个不幸的副作用,就是没有从someserver.com加载任何东西。
Another option is to use something like adblock plus, and just add the script to the "Add your own filters" tab, where the syntax for your filter will be: 另一种选择是使用诸如adblock plus之类的东西,只需将脚本添加到“添加您自己的过滤器”标签中,其中过滤器的语法为:
http://someserver.com/script.js
Hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.