Thursday, July 3, 2008

Debugging in javascript

General view on debugging posibilities
When developing webpages using javascript you have great debugging posibilities when errors occur. That is ofcause if you have the right tools installed on your computer/browser. I use Microsoft Visual Studio 2008 for javascript running in MSIE, and Firebug for javascript running in Firefox.

Both support breakpoints - though it is easier in Firebug. In MVS2008 I open the code and attach it to a running version of the code, after that I can add breakpoints. Firebug simply lets you add a breakpoint and volia it is active!

Debugging using own code
I found a post here: webdeveloper.com, modified it a litle and now have a stong debugging tool!

Below I have added some code which will allow you to show a "call stack" at any given point in your code. A call stack shows which functions with which parameters have brought us to a given place in your code. This allows you to find sources of errors more easy.
Furthermore it allows you the option to start the debugger if you wish! What more could you wish for! :-)

You can get the javascript code here:
http://www.netsi.dk/javascripts/showCallStack.txt

No comments: