问题
When my javascript code is contained in a HEAD block in my HTML file, it seems I can't set a breakpoint on it to debug it.
How can I do this?
alt text http://www.deviantsart.com/upload/mhmbha.png
this is what I see under the script tag:
alt text http://www.deviantsart.com/upload/17g116c.png
alt text http://www.deviantsart.com/upload/irki5p.png
alt text http://www.deviantsart.com/upload/mts9hn.png
Odd: when I take the javascript block OUT of my HTML <head> area, then the .htm page appears under scripts (kind of counter-productive):
alt text http://www.deviantsart.com/upload/5rfia.png
ok, the only solution I can find to this question is to put my HEAD scripts back into a .js file, anyone have a way to debug inline javascript?
回答1:
You should search for your code in the Script tab, you can't set breakpoints in the HTML tab.
Edit: In your second screenshot, you are looking the code of the Google JS API file, you can either, change the file manually (the red square at left on my screenshot), or use the search-box at the right:
回答2:
I found the problem.
instead of:
if($(this).next().is(':hidden')) {
I had:
if($(this).next().is(':hidden') {
i.e. the missing end-parenthesis was causing the javascript file (or .htm page including the javascript) not to show up under firebug "scripts".
回答3:
Enclose your functions in javascript with
debugger;
function blah
debugger;
回答4:
I don't think you can set breakpoints from the "HTML" tab in firebug.
Click over to the "script" tab, and find your script in the lower dropdown list, and you should be able to set a breakpoint from there.
回答5:
2016: Firefox, press F12, go to Debugger, look for your page (not a .js script)
https://developer.mozilla.org/en-US/docs/Tools/Debugger
来源:https://stackoverflow.com/questions/2174662/how-can-i-get-firebug-to-step-through-inline-javascript-code