Monday, March 24, 2008

JavaScript Debugging in Visual Studio 2005

We all know that "JavaScript Debugging" is one of the hottest feature of newly launched Visual Studio 2008 by Microsoft. In that we can add breakpoint and check the values in JavaScript in watch window at runtime also. Also Microsoft has added Intellisense for JavaScript. So indirectly..Life is much more simple now..Thanks to Microsoft for that..!! ;-)

Well..But what about Visual Studio 2005??..I am still using it..rather me and many of my friends like you people are using it.

Just we need to do set-reset some settings and we can also Debug JavaScript in Visual Studio 2005. I know very well that its not full fledge Debugging, but atleast you can see that its going to debug mode in your script and you can check values by selecting them and pressing Shift+F9 we usually do.

For this, First step is Start Internet Explorer, Go to "Tools" Menu, Click on "Internet Options", A wizard kind of Window will get open in front of you, Here you will see some 6-7 Tabs. Click on "Advance" Tab which is in last position. On clicking Advance Tab you will find some Tree like Categorized options with CheckBox to select-deselect it.

So under "Browsing" Category you can see on option check by default as "Disable Script Debugging (Internet Explorer)" , Uncheck this option if it is checked (Generally it is a checked option by default)

Now move to Visual Studio and just add a word "debugger;" in your script and run done with it, Once that Javascript will get fire, you will automatically get thrown in HTML Code window where you have written JavaScript.

Function HelloWorld()



    alert('Hello User !');



You can see that you can break through it with F10 step by step and watch values of variables if any inside it. I know though we are not able to add breakpoint physically in Visual Studio 2005, but this may help a lot.

Being a Web Developer by profession, I know how much pain my developers friend they suffer from each day just because they can't debug script like they debug their VB or C# code.

This one I tested on Internet Explorer 7 and its working well, As I don't have IE6 and I don't have SP for Vista so indirectly I don't have IE8 too..So I will try to check out this on both of them soon and will get back to you..between I am also trying hard to run this on Mozilla ;)


No comments: