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.
I spent 1 hour on this.
I had a
<script>
tag like this:Can you spot the problem?
Well it took me all that time to spot it. There's a missing
/
to close the<script>
tag.This is for sure due to some copy/paste and then trying to change the code... I just played the fool in this case! :)
After adding the
/
I was able to get the breakpoints working in Firebug. It makes sense.Finally I can see those blessed green numbers.
Just to add another possibility to those mentioned.
This one occurred when I was under pressure to fix something in production, naturally.
I had inadvertantely introduced a syntax error:
Just like that. At the beginning of the console log there was an error, but I didn't notice it. I kept trying to debug that file, but Firebug wouldn't step into it.
So, if this is happening to you: check the console, maybe there's a syntax error short-circuiting the loading of the file.
I had this problem too. Perhaps related to KIT-Inwi's answer... But I was generating random lines using PHP with each page load.
Firebug seems to remember the line number of the entire HTML page to put the breakpoint at, not necessarily the line of the Javascript, which means that the line number you put the breakpoint at on this page load won't necessarily be the same line of code next time you load it, so the breakpoint will appear to "jump".
I'm not sure how you'd resolve it with dynamic content that changes each time, but I fixed it by removing the random lines so the line with the breakpoint was the same on every page load.
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.
I was having this problem intermittently as well. I selected "disable all breakpoints" and the "enable all breakpoints" from the breakpoints drop down and it started working.