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.
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.
For me it worked after I removed every
document.write()
calls.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.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.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.
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.
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.