Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder complete's Avatar
    Join Date
    Jul 2005
    Location
    USA
    Posts
    87
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How does one go about debugging javascript?

    How does one go about debugging javascript?

    Do you use firebug and run your page through your localhost?

    If javascript is part of an ASP.NET application, I have found that the breakpoints in a .js file in Visual Studio seem to be ignored.

    The problem I see is that the ASP.NET application which uses javascript code has too versions -- a published and a debug version. The Debug version is located within my group of folders under the localhost. Also, when I launch the program through Visual Studio, it defaults to IE. Is there some way I can have it launch a different browser that will allow for javascript debugging?

    Is there a step-by-step description somewhere?

  • #2
    Regular Coder
    Join Date
    Jan 2013
    Location
    Germany
    Posts
    578
    Thanks
    4
    Thanked 77 Times in 77 Posts

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,233
    Thanks
    80
    Thanked 4,456 Times in 4,421 Posts
    I'm going to stick my neck out on this one, since I'm not part of that other forum and happen to know the answer.

    (1) Don't use FF or IE, if possible. Use Chrome. It's the easiest to use JS debugger. The big failing of the IE debugger is that it can't catch and then tell you about errors that happened before you turned it on, so you have to turn it on and then refresh the page, which means you may have to do many more steps to get to the point of failure again. Ugh.

    (2) Don't launch your ASP.NET page from Visual Studio. Bring up Chrome and then type in the URL to the page, even if it's http://localhost/something.aspx
    Then hit the F12 key to turn on the debugger. Presto. Easy. I do it all the time.

    (3) And if it's not obvious: Don't use Visual Studio as your JS debugger, ever. It worked okay back in ASP.NET version 1.1 days, but the debuggers built into the browsers--even the one in IE--are so much better than VS for debugging JS that it's never worth the hassle.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I also don't like IE dev tools very much but the upcoming IE11 dev tools look very good and maybe even better than Chrome and Firebug.

    Watch this video showing the IE11 dev tools.

    http://channel9.msdn.com/Events/Build/2013/4-073
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,316
    Thanks
    29
    Thanked 280 Times in 274 Posts
    Quote Originally Posted by complete View Post
    How does one go about debugging javascript?

    Do you use firebug and run your page through your localhost?
    I use Firefox. Ctrl+Shift+K brings up the error console, Ctrl+Shift+I brings up the generated DOM, and Ctrl+Shift+Q lets you monitor the network. Firefox also has a font inspector.

    I also use XAMPP to test files locally, which saves time over constantly uploading the files to a live server.

    Quote Originally Posted by glenngv View Post
    I also don't like IE dev tools very much but the upcoming IE11 dev tools look very good and maybe even better than Chrome and Firebug.
    I have IE11/Windows 8.1 Developer Preview installed. While the tools are a big improvement over IE10, they have some drawbacks. In particular:

    • The console still only records errors after it's opened and you refresh the page.
    • The console reports useless things like indicating that an XSLT transformation occurred.
    • Microsoft removed the compatibility modes switcher for older versions of IE, which, while not entirely accurate, were quicker to use than booting up a virtual machine (which could always be done at the end for further bugfixing). There's a mode field in the options that reflects the state of the document, but you can't change the value.
    • It still uses F12 key activation, which is annoying because I have to physically look at my keyboard every time I need to use it. I can find shortcuts in Firefox and Chrome (Ctrl+Shift+I/J) without even looking at the keyboard. But that's just a personal thing, I guess.

    On the other hand:
    • You can have the console up while any other developer pane is open, which I don't think any other browser has out of the box.
    • The UI is large and readable, which I assume is for touch compatibility.
    • It also has a better Trace tool than Chrome when it comes to determining the font in use. (But Firefox is still better.)
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by Old Pedant View Post
    (2) Don't launch your ASP.NET page from Visual Studio. Bring up Chrome and then type in the URL to the page, even if it's http://localhost/something.aspx
    Then hit the F12 key to turn on the debugger. Presto. Easy. I do it all the time.
    In Visual Studio 2012, you can choose which browser to use by default when launching the site. There is a dropdown in the toolbar that lists all the browsers installed. I don't know if previous versions have the same feature.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,233
    Thanks
    80
    Thanked 4,456 Times in 4,421 Posts
    Ahhh...no, I'm still using VS2008. I was given a copy and am too cheap to update. <grin/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •