views:

1772

answers:

5

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.

+3  A: 

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.

spoulson
Nope, refreshing the page doesnt help. They don't have green line numbers as well.
DotnetDude
+1  A: 

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.

Eric Wendelin
+2  A: 

I'm having this problem very often too. I've found out that reopening the tab seems to help (the breakpoints are not lost). But "Break on all errors" looks to be the most reliable way for breaking.

I rarely have to something good about IE, but in this case it gets it right. Debugging JavaScript in VS just works. It hits breakpoints ("debugger") without a problem and stops all other JavaScript code on the page from executing. So I use it as a back-up quite often.

Tsvetomir Tsonev
+1  A: 

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.

Nathan
+1  A: 

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.

Ray Vega