Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Firebug to step-through inline javascript code?

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?

like image 617
Edward Tanguay Avatar asked Feb 01 '10 04:02

Edward Tanguay


People also ask

Can you debug inline JavaScript?

Use the sources tab, you can set breakpoints in JavaScript there. In the directory tree underneath it (with the up and down arrow in it), you can select the file you want to debug. You can get out of an error by pressing resume on the right-hand side of the same tab.

How do I use JavaScript inline?

Inline JavaScript can be achieved by using Script tag inside the body of the HTML, and instead of specifying the source(src=”…”) of the JavaScript file in the Script tag, we have to write all the JavaScript code inside the Script tag.

How do I debug JavaScript in HTML code?

Start debugging Set the breakpoints in the JavaScript code, as required. Open the HTML file that references the JavaScript to debug or select the HTML file in the Project tool window. From the context menu of the editor or the selection, choose Debug <HTML_file_name>.

What is inline JavaScript code?

In JavaScript, inline function is a special type of anonymous function which is assigned to a variable, or in other words, an anonymous function with a name.


1 Answers

You should search for your code in the Script tab, you can't set breakpoints in the HTML tab.

alt text

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:

firebug search

like image 167
Christian C. Salvadó Avatar answered Oct 21 '22 18:10

Christian C. Salvadó