简体   繁体   English

在Google Chrome中检查jsfiddle.net上的javascript

[英]Inspecting javascript on jsfiddle.net in Google Chrome

Is it possible to set breakpoints using the google chrome inspector on javascript code entered into jsfiddle.net? 是否可以使用谷歌浏览器检查器在输入jsfiddle.net的javascript代码中设置断点?

When I go to the script tab of the developer tools I see lots of scripts but I don't know where my script would be found or if it can be found in there at all. 当我进入开发人员工具的脚本选项卡时,我看到很多脚本,但我不知道我的脚本会在哪里找到,或者是否可以在那里找到它。 In the past I have just settled for some console.log action but I would love to set some breakpoints. 在过去,我刚刚安排了一些console.log动作,但我想设置一些断点。

(If not possible I am interested in other ways of inspecting javascript in this scenario.) (如果不可能,我对在这种情况下检查javascript的其他方式感兴趣。)

Debugger calls work fine on jsfiddle. 调试器调用在jsfiddle上正常工作。 Just enter this line where you want to start debugging: 只需在要开始调试的行中输入:

debugger;

Debugger is great for starting debug mode in chrome, firebug and even IE dev tools, but you usually need to have the debugger started (ie "start debugging" in IE, open firebug/developer tools). 调试器很适合在chrome,firebug甚至IE dev工具中启动调试模式,但是你通常需要启动调试器(即在IE中“开始调试”,打开firebug /开发人员工具)。

In the Developer Tools, under the Script tab if you select fiddle.jshell.net from the dropdown, around line 20-30 (depending on how much CSS you have) you will see a <script> tag that contains the code from the Javascript fiddle window. 在开发人员工具中,在脚本选项卡下如果从下拉列表中选择fiddle.jshell.net ,在第20-30行(取决于您拥有多少CSS),您将看到包含来自Javascript的代码的<script>标记小提琴窗。 You can set your breakpoints here. 您可以在此处设置断点。

You can also evaluate code in the Console against this frame by changing the console context: 您还可以通过更改控制台上下文来评估控制台中针对此框架的代码:

Another trick is to show your fiddle without the editor using the following syntax: 另一个技巧是使用以下语法在没有编辑器的情况下显示您的小提琴:

<normal path to your fiddle>/show/light/

as an example: jsfiddle-link 举个例子: jsfiddle-link

From the developer console go to tab sources , open the sources tree representation (on the left), open the fiddle.jsshell.net node, next click _display , next (index) and you should see your code. 从开发者控制台去片 ,打开源树表示(左侧),打开fiddle.jsshell.net节点,接下来点击_display ,未来(index) ,你应该看到你的代码。

Note that if you save your code this _display reference will be replaced by fiddle-reference/version/show . 请注意,如果您保存代码,则此_display引用将替换为fiddle-reference/version/show For example JsQfE/2/show (which doesn't exist as far as I know but does the job as an example) . 例如JsQfE/2/show (据我所知,它不存在,但以作业为例)

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM