How to debug with command line in Chrome
I am recently working on dojo. And sometimes I need the help of chrome debugger help to understand how the function actually works. But right now, I have a problem. I want to add a breakpoint at a specified function. I know the function name already. But since the dojo source file is compressed, I cannot add the breakpoint at the specified line directly开发者_JS百科. I noticed that there is a way to debug javascript with commandline in Chrome2. But right now, I cannot find the debugger with commandline capability. Does the latest Chrome have any command line tools for debugging or just a graphical one?
Thanks!
I think you need to get yourself an unminified version of dojo. It comes in the development kit and is called dojo.js.uncompressed.js
(use this file instead of dojo.js). You can search the code with your text editor, find the line you want and set a breakpoint there.
You could also use the good old debugger keyword, that has been with JavaScript since v1.0
https://developer.mozilla.org/en/JavaScript/Reference/Statements/debugger
if(!dojo)
debugger;
By using the Web Inspector which is included with Google Chrome, you can use the command line console issuing various JavaScript commands: http://blog.chromium.org/2009/06/developer-tools-for-google-chrome.html
- Right click on your page, choose "Inspect element",
- Click on the console tab.
- Start typing.
There are other debuggers as well such as Chrome developer tools for Eclipse, http://blog.chromium.org/2009/08/google-chrome-developer-tools-for.html, it is kind of nice using the Eclipse debugger.
精彩评论