我想调试嵌入在 HEAD 元素中的 javascript 文件。
我导航到该站点,查看代码并设置断点:
(来源:deviantsart.com)
但是当我单击Reload时,脚本会消失并且不会在断点处停止:
(来源:deviantsart.com)
调试工作较早,所以我知道它通常可以工作。我该怎么做才能让 Firebug 始终调试我的脚本?
我想调试嵌入在 HEAD 元素中的 javascript 文件。
我导航到该站点,查看代码并设置断点:
(来源:deviantsart.com)
但是当我单击Reload时,脚本会消失并且不会在断点处停止:
(来源:deviantsart.com)
调试工作较早,所以我知道它通常可以工作。我该怎么做才能让 Firebug 始终调试我的脚本?
我之前也注意到了这种行为。如果您在调试器运行时刷新页面(即在您遇到断点并单步执行代码之后),似乎可能会发生这种情况。这远非结论性的,只是我随时间随便观察到的。
此外,我尽量避免在 firebug 处于活动状态时打开多个选项卡,因为它似乎会让人感到困惑。
编辑:只是想补充一点,我已经以几种不同的方式看到了这个清单本身:
外部脚本文件根本不会出现在脚本面板中。
外部脚本文件出现,但萤火虫没有“看到”它。您知道这已经发生,因为可以设置断点的代码旁边的行号不会突出显示(以前是绿色,但现在看起来只是比其他行更暗)。我已经看到 HTML 页面上的内联 javascript 也会发生这种情况(太可怕了!)。
关闭Firefox,然后重新启动。有时萤火虫会感到困惑。还要确保您拥有最新版本。
您需要激活脚本选项卡
In our case it was the bundling of JS files.
It is not only FireFox
, it is same for Chrome
.
We moved the file out of the bundle and put it on the page where it needed to be referenced and it started working like charm.
The bugs in script processing that I know about are 1) jquery dynamic loading of scripts fails, 2) new Function() cannot be seen, 3) some kinds of document.write() cannot be seen.
Firebug processes script files in series with Firefox. This means that Firebug must be active when the page loads and it means that any exception in the path will cause the files to be mis-processed. If you opened firebug before loading and you still see problems, then the most likely fix is to install Firebug in a new Firefox profile. This causes you to get a completely fresh set of default options and you run Firebug without other extensions. As you re-add other extensions, look for problems in seeing scripts: then maybe you will discover what extension is interfering with the code path for processing scripts. I know this is a pain in the neck, but so is JS debugging without source ;-). We are working on testing with more Firebug and Firefox extensions installed to try to reduce these problems.
我不确定拥有<script>
inside <head>
(而不是 inside <body>
)实际上是合法的 HTML。如果不是,我怀疑,你不能责怪 Firebug 没有很好地支持它......!-)