help.net


Musing on .Net

News





hit counters




Open source CMS


Technorati

My blog

Irish blogs

Locations of visitors to this page Get Chitika eMiniMalls

.Net useful

Blogs I read

PocketPC

SQL

Usability

Debugging Javascript in Visual Studio .NET

Just a reminder to myself but this can be useful if you are dealing a lot with Ajax stuff!

- Open in Internet Explorer Tools -> Internet Options -> Advanced tab.
- Deselect the following (make the checkbox unchecked):

[ ] Disable Script Debugging

- Restart IE.
Now just add the following line of code to your JavaScript - it'll work as a breakpoint:

debugger;

Visit your page with the javascript using your fresh instance of IE, a window should prompt you to select a debugging environment. Select the MSVS.NET instance you have opened (or you could select 'New instance of Microsoft Development Environment'), and click 'Yes'.

Another window will prompt you to 'Choose the program types that you want to debug:' - make sure 'Script' is the only option selected, and click 'Ok'

Enjoy!

Posted: Apr 26 2006, 02:38 PM by help.net | with 5 comment(s)
Filed under: , ,

Comments

Dave said:

Back in 99 or so I discovered the debugger; statement. Its great when it works but sometime it will just get skipped. In the example below function "a" may break into debugging but "b" may not. Its really hit and miss. I've gone through different versions of IE, different debugger's, different machines, yet the problem still persists after all these years. :-(



function a()
{
debugger;
alert('hello');
}

function b()
{
alert('hello');
debugger;
}
# April 26, 2006 1:02 PM

AndrewSeven said:

I have a tendency to lauch from the browser using :

View | Script Debugger | Break at next statement
# April 26, 2006 2:11 PM

jayson knight said:

What's wrong with just attaching to the iexplore.exe instance you want to debug from VS?
# April 26, 2006 4:39 PM

Paschal said:

Nothing wrong Jayson just another approach :-)
# April 26, 2006 4:51 PM

anon said:

Just use Firefox & Venkman javascript debugger.
# April 27, 2006 5:21 AM