开发者

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

  1. Right click on your page, choose "Inspect element",
  2. Click on the console tab.
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜