Showing posts with label debugging. Show all posts
Showing posts with label debugging. Show all posts

Friday, November 7, 2008

Snippet: External javascript Eval window

Below a code which (especially) in MSIE will be helpfull when debugging a webpage in frontend. The script opens a small window containing a textarea where you may enter your javascript code. When you Evaluete the code it will be in the context of the current window, so you can examine or edit the DOM tree of the document which is in the window where you clicked the Snippet.

You should create your snippet by

  1. Create a bookmark (any page)
  2. Place the bookmark in the "links" area, so that it will be available in your toolbar
  3. Edit the bookmark (right click) and paste the code below into the URL
  4. Rename it (to say "EVAL")

Here is the code:



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