Firebug - Breakpoint doesn't hit

2019-04-03 01:19发布

I am setting breakpoints in an external JS file and I haven't been able to get Firebug hit the breakpoint in a consistent way. It works sometimes but most of the times it doesn't. The only way I can get it to work is by switching on "Break on all errors"

I have used the debugger; statement as well without any luck.

11条回答
Deceive 欺骗
2楼-- · 2019-04-03 01:49

Does the 'Console' tab on Firebug show errors for any of your other JavaScript? I found that if JavaScript errors exist for code prior to a debug breakpoint then it will never reach that line of code until the preceding broken one(s) are fixed.

查看更多
狗以群分
3楼-- · 2019-04-03 01:50

For me it worked after I removed every document.write() calls.

查看更多
Emotional °昔
4楼-- · 2019-04-03 01:50

Same problem with FF 36 and FB 2.0.8: no errors in the console, the code works fine, but FB displays HTML instead of JS, stops at debugger breakpoint but shows it at some random HTML line, does not stop at the regular breakpoints.

I resolved it by extracting JS from the page and moving it into its own JS file.

But there was a catch: when the script resided in its own JS file, I could not get the "global" variables to work in FF (worked fine in IE regardless of where the code was), even using window.varName syntax. So ended up debugging in FB from a separate file, but reverted to inline for production.

查看更多
三岁会撩人
5楼-- · 2019-04-03 01:52

Does Firebug show the code in the Script tab with green line numbers? This indicates debuggable lines of code.

I've experienced this symptom where none of the line numbers were green at times. I refresh the page and magically, they're green again.

查看更多
走好不送
6楼-- · 2019-04-03 01:53

I have experienced this problem when trying to debug pages within frames using Firebug 1.4. Selecting "Show only this frame" or "Open frame in new tab" from the "This frame" context menu then refreshing the page seems to make the scripts debuggable.

查看更多
Melony?
7楼-- · 2019-04-03 01:54

If the line numbers aren't green, it seems like Firebug cannot debug that part of code because it is out of scope. So, if you're using something like $(function () { ... }); Firebug will not be able to access Functions and variables.

Does that make sense?

Also, is it possible that some other function or something is overriding the one you're trying to debug. It's even possible if you're including the same JS file twice.

Hope that helps.

查看更多
登录 后发表回答