Wednesday, August 26, 2009

How to Debug JavaScript With Firebug

Step 1

Conduct a simple Internet search to find the Firebug application and install it as a Firefox extension. After installation there should be a green check mark at the bottom right corner of your browser.
Step 2

Open the Javascript HTML file you wish to debug. When it opens you should see an alert box that shows a series of ascending numbers and then the term "undefined" at the end of the string. The "undefined" is where your bug is.
Step 3

Press the green check mark at the bottom of your browser to open the Firebug debug panel.
Step 4

Switch to the script tab and define your breakpoint. A breakpoint suspends the debugging process when it is encountered. Reload the page.
Step 5

Click the "step over" button. Firebug is updating all the variables until your breakpoint and listing them on the right side of the debug window.
Step 6

Watch the program step through the code and follow the values it defines on the right side of the debug window to find the root of your bug.
Step 7

Spot the problem and retype the correct code. Run Firebug to make sure the problem is fixed

No comments:

Post a Comment