[英]How to disable JavaScript in Chrome Developer Tools?
I am trying to debug the features of a website when users disable their JavaScript.当用户禁用他们的 JavaScript 时,我试图调试网站的功能。 I was wondering how do you disable JavaScript for a page from the Google Chrome DevTools?
我想知道如何从 Google Chrome DevTools 禁用页面的 JavaScript?
Update August 2020 2020 年 8 月更新
Original answer原答案
Official documentation: Disable JavaScript With Chrome DevTools官方文档: 使用 Chrome DevTools 禁用 JavaScript
There's now a command menu built into DevTools that makes it easier to disable JavaScript.现在 DevTools 中内置了一个命令菜单,可以更轻松地禁用 JavaScript。 This has been around as of April 2016 or so.
这大约是在 2016 年 4 月左右。
Disable JavaScript
(or some version of that... it's a fuzzy search) and then press Enter .Disable JavaScript
(或某个版本的...这是一个模糊搜索),然后按Enter 。 Use the Enable JavaScript
command when you want to turn it back on.当您想重新打开它时,请使用
Enable JavaScript
命令。
chrome://settings/content
Javascript/管理异常
This extension makes it faster (I am the author) : Quick Javascript Switcher这个扩展使它更快(我是作者): Quick Javascript Switcher
It is open source: https://github.com/maximelebreton/quick-javascript-switcher它是开源的: https : //github.com/maximelebreton/quick-javascript-switcher
You can also run Chrome with JavaScript disabled by default by using the flag:您还可以使用以下标志在默认情况下禁用 JavaScript 的情况下运行 Chrome:
-disable-javascript
You would use this for example by running Chrome like this:例如,您可以通过像这样运行 Chrome 来使用它:
C:\Documents and Settings\%username%\Local Settings\Application Data\Google\Chrome" -disable-javascript
The quickest way is problably this one:最快的方法可能是这个:
On OSX, I had to click the triple vertical dots, and uncheck a box in the settings section.在 OSX 上,我必须单击三个垂直点,然后取消选中设置部分中的一个框。 Which can also be opened with
f1
也可以用
f1
打开
Using only the keyboard at least for Windows 10:至少在 Windows 10 中仅使用键盘:
To temporarily block JavaScript on a domain :要临时阻止域上的 JavaScript:
View site information
)View site information
)JavaScript
, select Always block on this site
JavaScript
旁边的下拉列表中,选择Always block on this site
On Mac OS X:在 Mac OS X 上:
The Chrome Quick JavaScript Switcher extension is a lot easier though :-)不过, Chrome Quick JavaScript Switcher 扩展要容易得多:-)
The gear icon is no longer part of developer tools.齿轮图标不再是开发人员工具的一部分。 Since Chome 30.0 it is not even possible to bring it back ( In Google Chrome Developer Tools, the toolbar icons disappeared. What gives? )
由于 Chome 30.0 甚至无法将其恢复( 在 Google Chrome 开发者工具中,工具栏图标消失了。是什么给的? )
The first way第一种方式
⋮
button in the top right corner of the Developer Tools, then click Settings
in the menu.⋮
按钮,然后单击菜单中的Settings
。 Then you have to scroll down the settings window to bottom and then you will see the checkbox for disabling JavaScript like follows:然后您必须将设置窗口向下滚动到底部,然后您将看到禁用 JavaScript 的复选框,如下所示:
Just click on this checkbox and push esc key on keyboard for hide the settings.只需单击此复选框并按键盘上的esc键即可隐藏设置。 If you want to enable it then you have to do the same way again.
如果要启用它,则必须再次执行相同的操作。
The second way第二种方式
If all this does not work如果这一切都不起作用
For some reason it is possible that it does not work.由于某种原因,它可能不起作用。 I this case open a new empty site in "Incognito Mode" and do all this there.
我在这种情况下以“隐身模式”打开一个新的空站点,然后在那里执行所有操作。
The quickest way最快的方式
In Chrome Web Store or on Opera Addon site you can find and install extensions which do it per one click.在 Chrome 网上应用店或 Opera Addon 站点上,您可以找到并安装扩展程序,这些扩展程序一键即可完成。 Just search
"Javascript Switcher"
:只需搜索
"Javascript Switcher"
:
Press F8 for temporarily freezing / unfreezing JS (with DevTools open).按F8临时冻结/解冻 JS(打开 DevTools)。
This is very useful for debugging UI issues on elements that may lose focus if you click or press anything outside of that element.这对于调试元素上的 UI 问题非常有用,如果您单击或按下该元素之外的任何内容,这些元素可能会失去焦点。 (Chrome 71.0.3578.98, Ubuntu 18.10)
(Chrome 71.0.3578.98,Ubuntu 18.10)
Paste it: chrome://settings/content粘贴它:chrome://settings/content
Go to "Javascript" section and disable it.转到“Javascript”部分并禁用它。
Chrome://chrome/settings/Privacy/Content settings/JavaScript
在那里您可以在Manage exceptions..
粘贴您网站的 URL Manage exceptions..
并将 JavaScript 优先级从允许更改为阻止。
这是 windows 的最新设置
Settings > Advanced > Privacy and security > Site Settings > Javascript > Blocked then get switch on and off
good question, i try so many way, but it is curry and boring, until i find shortcut.好问题,我尝试了很多方法,但它是咖喱和无聊,直到我找到捷径。
only two shortcut, but i think safari is more convenient for that.只有两个捷径,但我认为 safari 更方便。
There's a settings in chrome chrome 中有一个设置
open the menu from chrome, click settings > type in "javascript" in the search bar > click site settings > click javascript.从 chrome 打开菜单,单击设置 > 在搜索栏中输入“javascript”> 单击站点设置 > 单击 javascript。
from here you can toggle javascript specifically to a site using their url.从这里您可以使用 url 将 javascript 专门切换到站点。 or just click the big button to allow/block it to all sites.
或者只需单击大按钮以允许/阻止它访问所有站点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.