调试动态添加的javascript文件 [英] Debugging dynamically added javascript files

查看:115
本文介绍了调试动态添加的javascript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,可以根据用户选择的方式动态添加JavaScript文件,以便实时使用ajax来避免刷新屏幕。



我现在尝试调试这些动态添加的JavaScript文件,并尝试过Google Chrome的开发人员工具和Firebug的Firefox插件,并注意到动态添加的javascript文件不会显示,因此我无法选择它们来添加断点等。 / p>

那么,是否有解决方案,即调试动态添加的javascript文件?

解决方案

您可以在要设置断点的动态脚本中添加调试器; 语句。如果执行线程在开发工具UI被打开时执行线程到达语句,这将使得chrome停止在它上面。



您也可以启动脚本,所以您的脚本出现在调试器中,您可以在之后手动设置断点。


I have a web application which dynamically adds javascript files based on what the user chooses as options using ajax in real time to avoid refreshing the screen.

I am now trying to debug these dynamically added javascript files and have tried both Google Chrome's developer tools and Firebug's pluggin for Firefox, and have noticed that the dynamically added javascript "files" do not appear, so I can't select them to add breakpoints etc.

So, is there a solution for this, i.e. debugging dynamically added javascript files?

解决方案

You can add the debugger; statement in your dynamic scripts where you want to set the breakpoint. This will make chrome stop on it like a regular breakpoint if the execution thread reaches the statement while the developper tools UI is opened.

You can also start your script with that, so your script appears in the debugger, and you can after that manually set a breakpoint where you want.

这篇关于调试动态添加的javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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