如何在Chrome中的内联JavaScript中添加断点 [英] How to add breakpoints in your inline javascript in chrome

查看:661
本文介绍了如何在Chrome中的内联JavaScript中添加断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调试我的JavaScript代码,并能够在源选项卡下成功地将断点放置在必需的位置。

I want to debug my javascript code and able to successfully place breakpoints at required places under sources tab.

但是,我遇到了一个问题,我想调试我的内联JavaScript代码。我们有任何Chrome调试工具功能,我可以使用它调试我的内联JavaScript代码。

However, I have run into an issue where I want to debug my inline javascript code. Do we have any chrome debugging tool feature using which I can debug my inline javascript code.

使用Firebug也可以调试目的。

I am fine with using Firebug too for debugging purpose.

PS:通过内联JavaScript代码,我的意思是身体标签内的JS代码和同一个文件。

PS: By inline javascript code, I mean JS code inside body tag and in the same file.

推荐答案

另一种方法可以使用动态脚本方法。
Chrome提供了简单的解析器命令,可以标记动态加载的JS。

Another way can be using the dynamic script method. Chrome provides simple parser command which can tag dynamically loaded JS.

<script type="text/javascript">
[...]
//# sourceURL=dynamicScript.js 
</script>

此行告诉chrome调试器脚本标签内的整个脚本应该被解释为一个dynamicScript。 js文件。您可以在调试器列表中找到该文件,并轻松设置断点或检查代码。

This line tells the chrome debugger that this whole script inside the script tag should be interpreted as a dynamicScript.js file. You can find the file on the debugger list and easily set up breakpoints or check the code.

注意:@被替换为#以避免不支持的浏览器出现错误

Note : @ is replaced by # to avoid errors on unsupported browsers

动态JavaScript中的断点

这篇关于如何在Chrome中的内联JavaScript中添加断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆