Click here to Skip to main content
13,152,194 members (35,238 online)
Click here to Skip to main content
Add your own
alternative version


57 bookmarked
Posted 24 May 2007

Using Visual Studio to Debug JavaScript in IE

, 24 May 2007
Rate this:
Please Sign up or sign in to vote.
Using Visual Studio to debug JavaScript in IE can really speed up your JavaScript development and save you some headaches

Using break points to debug your javascript


Anyone who has done some work with JavaScript knows it can be very frustrating. Often you have to use: Alert("I am here"); type of code to debug it. Visual Studio and IE (Internet Explorer) have the ability to debug JavaScript code, including setting break points in your JavaScript.


When I started working in .NET, I was a VB.NET Windows programmer. When I started to use ASP.NET, the need to use JavaScript started to come up. It was easy for me to make mistakes in my JavaScript since it is a C based language, so there was a real need to have the ability to debug my JavaScript code. I don't think I would have ever ventured into the JavaScript world without being able to debug it in Visual Studio.


In IE you have to enable script debugging. Go to Tools, then Internet Options. Click on the Advanced Tab. Un-check disable script debugging (Internet Explorer). It is checked by default.

Advanced tab to enable script debugging

NOTE: you will find with script debugging enabled that many Internet sites have lots of JavaScript problems. So I would suggest only turning this on when you want to debug your JavaScript otherwise you will be bothered by IE asking you if you want to debug other peoples bad JavaScript.

Once you have this set, a new option is available in your View menu. If you click on View there is now a script debugger option. If you are using IE 7 you will need to click on Tools, then Menu bar to see the View menu item.

Screenshot - Scriptdebug1.gif

So at this point in Visual Studio, if you set your web project / web site to debug mode and run it, you can debug your JavaScript.

Under View/Script Debugger there are two options. The first is Open.

Screenshot - Scriptdebug3.gif

This will open the HTML/JavaScript in Visual Studio and allow you to set break points in your JavaScript.

Screenshot - Scriptdebug4.gif

The other option is Break at next statement which does just what it says. When the next JavaScript gets run, you will go into Visual Studio and it will break on the first JavaScript line.

Screenshot - Scriptdebug6.gif

Once you are in the Visual Studio debugger, you can use all of the normal tools you have to investigate variables etc. to help with the debugging of the JavaScript code.

Using VS tools to debug


I have found that being able to debug my JavaScript has really helped me to find all the small problems and bugs that are so easy to create when writing JavaScript code.
I hope this article helps you in your JavaScript debugging.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
I started my programmer career over 21 years ago doing COBOL and SAS on a MVS mainframe. It didn't take long for me to move into windows programming. I started my windows programming in Delphi (Pascal) with a Microsoft SQL server back end. I started working with when the beta 2 came out in 2001. After spending most of my programming life as a windows programmer I started to check out in 2004. I achieved my in April 2005. I have done a lot of MS SQL database stuff. I have a lot of experience with Window Service and Web services as well. I spent three years as a consultant programing in C#. I really enjoyed it and found the switch between and C# to be mostly syntax. In my current position I am programming in C# working on WPF and MSSql database stuff. Lately I have been using VS2015.

On a personal note I am a born again Christian, if anyone has any questions about what it means to have a right relationship with God or if you have questions about who Jesus Christ is, send me an e-mail. ben.kubicek[at]netzero[dot]com You need to replace the [at] with @ and [dot] with . for the email to work. My relationship with God gives purpose and meaning to my life.

You may also be interested in...


Comments and Discussions

GeneralRe: Is there a system field that hold the value of a JavaScript delimiter? : or $ Pin
smcirish10-Mar-09 6:43
membersmcirish10-Mar-09 6:43 
GeneralRe: Is there a system field that hold the value of a JavaScript delimiter? : or $ Pin
kubben10-Mar-09 7:50
memberkubben10-Mar-09 7:50 
GeneralRe: Is there a system field that hold the value of a JavaScript delimiter? : or $ Pin
smcirish10-Mar-09 7:58
membersmcirish10-Mar-09 7:58 
GeneralRe: Is there a system field that hold the value of a JavaScript delimiter? : or $ Pin
kubben10-Mar-09 8:07
memberkubben10-Mar-09 8:07 
GeneralThanks it is giong to help all JS user Pin
santosh d30-Jan-09 19:21
membersantosh d30-Jan-09 19:21 
GeneralRe: Thanks it is giong to help all JS user Pin
kubben31-Jan-09 1:12
memberkubben31-Jan-09 1:12 
GeneralThank you! Pin
mohamed antar4-Aug-07 3:28
membermohamed antar4-Aug-07 3:28 
GeneralRe: Thank you! Pin
kubben4-Aug-07 6:15
memberkubben4-Aug-07 6:15 
Questionwhat abt web resource file Pin
theMukesh12330-May-07 19:32
membertheMukesh12330-May-07 19:32 
AnswerRe: what abt web resource file Pin
kubben31-May-07 1:49
memberkubben31-May-07 1:49 
GeneralSome Other Debugging Tips [modified] Pin
Nick Taylor30-May-07 3:01
memberNick Taylor30-May-07 3:01 
GeneralRe: Some Other Debugging Tips Pin
kubben30-May-07 3:17
memberkubben30-May-07 3:17 
GeneralAnother side note Pin
Brad Ford29-May-07 7:36
memberBrad Ford29-May-07 7:36 
GeneralRe: Another side note Pin
kubben29-May-07 7:41
memberkubben29-May-07 7:41 
Generalthanks! Pin
stefano piuri29-May-07 2:47
memberstefano piuri29-May-07 2:47 
GeneralRe: thanks! Pin
kubben29-May-07 2:54
memberkubben29-May-07 2:54 
Generalside note Pin
dustkicker28-May-07 22:36
memberdustkicker28-May-07 22:36 
GeneralRe: side note Pin
kubben29-May-07 1:37
memberkubben29-May-07 1:37 
GeneralThanks! Pin
merlin98124-May-07 11:35
membermerlin98124-May-07 11:35 
GeneralRe: Thanks! Pin
kubben24-May-07 13:50
memberkubben24-May-07 13:50 
GeneralRe: Thanks! Pin
Orcrist24-May-07 18:25
memberOrcrist24-May-07 18:25 
GeneralRe: Thanks! Pin
kubben25-May-07 1:37
memberkubben25-May-07 1:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170924.2 | Last Updated 24 May 2007
Article Copyright 2007 by kubben
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid