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条回答
甜甜的少女心
2楼-- · 2019-04-03 01:58

I spent 1 hour on this.

I had a <script> tag like this:

<!-- jQuery Validate -->
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js" type="text/javascript">

Can you spot the problem?

Well it took me all that time to spot it. There's a missing / to close the <script> tag.

<!-- jQuery Validate -->
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js" type="text/javascript" />

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.

查看更多
神经病院院长
3楼-- · 2019-04-03 02:00

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:

function: myFunc(){}

// function body

}

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.

查看更多
Bombasti
4楼-- · 2019-04-03 02:01

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.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-04-03 02:06

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.

查看更多
姐就是有狂的资本
6楼-- · 2019-04-03 02:09

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.

查看更多
登录 后发表回答