Best way to trace Javascript code [closed]
What is the best way to debug Javascript code using any tool..i.e. i want to know when a button is clicked, what all JS code gets executed...
I wanted to test in Firefox and Safari..Already tried Firebug, but want to know if there is any better way开发者_开发问答..
Also more importantly i want to know "how" exactly to debug the code?
Also is it possible to print the complete JS code that gets called when I say press a button?
I always use the integrated web inspector tool from Google Chrome (you know, right-click, Inspect element). It works quite well for me, and has all the functions I need.
This post, using FireFox's FireBug and jQuery, might help you detect and capture all of the events bound to a button so you can tell what JS code is run when the button is clicked:
How to debug JavaScript/jQuery event bindings with Firebug (or similar tool)
Chrome Developer Console + Firefox Firebug of course (and Firebug Lite in IE), but also check out Visual Event, a bookmarklet that show you a highly visual overview of events attached to elements of your page.
Well, I think that the best method is using Visual Studio and hooking it with Internet Explorer. As many others have pointed out, the browser built-in tools are great, but visual studio lets you debug javascript code and edit it with same application. The downside is that you must use Internet Explorer, but personally I don't find it to be such a big problem.
Chrome Developer Console + Firefox Firebug
精彩评论