Reputation: 193372
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?
Upvotes: 11
Views: 19837
Reputation: 17039
2016: Firefox, press F12, go to Debugger, look for your page (not a .js script)
https://developer.mozilla.org/en-US/docs/Tools/Debugger
Upvotes: 0
Reputation: 193372
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".
Upvotes: 4
Reputation: 827744
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:
Upvotes: 4
Reputation: 15599
Enclose your functions in javascript with
debugger;
function blah
debugger;
Upvotes: 4
Reputation: 116987
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.
Upvotes: 0