---By Jimmy.Shine
调试Javascript的方法,整理笔记时发现,与大家共享。
@see Professional JavaScript for Web Developers by
Nicholas C.Zakas,by Wiley Publishing
JavaScript高级程序设计 人民邮电出版社出版中文版
Venkman 作为Mozilla的调试器,是针对Mozilla(Firefox)的自
由工具。安装路径为:
http://www.hacksrus.com/~ginda/venkman/。在此,会发现一个
vendkman的列表,点击最新版本旁边的Install的链接。
1. 要运行Venkman,可点击Tools->Web Development->JavaScript
Debugger来手工打开窗口。此后,venkman的窗口会将所有包含有
javascript的文件自动载入调试器窗口。也可以在代码中使用
debugger命令。一旦遇到debugger命令,调试器会自动开启并在这
一行代码上停止执行。
2. 在Venkman中的视图
1)Loaded Script
显示包含JavaScript的文件,HTML或是外部JavaScript文件。
然后展开每个文件会出现其中包含的函数,显示函数名和函数开始
的行号。
2)Open Windows
显示Mozilla打开的所有浏览器窗口(和标签页)。在每个窗口下
是已经载入的HTML文件,再下面是JavaScript文件的列表。可以通
过右键点击文件然后选择Set As Evalution Object来在不同的窗
口之间切换调试器的焦点。
3)Local Variables
遇到断点时,该视图中便会出现正在执行的代码的范围内可用
的所有变量的列表。如果变量包含的是对象,也可以展开变量名来
查看对象所有的特性。在断点处停止执行后,如果要更改变量的值
,可以双击变量名,然后输入新的值。
4)Watches
显示调试器会话的监视器的列表。监视器的工作就是监视变量
值的变化。一旦变量的值发生变化,Watches视图中就会自动更新
。
5)Breakpoints
显示调试器会话中已经注册的断点的列表。
6)Call Stack
遇到断点时,该视图会显示调用堆栈(到断点处的函数调用的序
列)。
7)Source Code
显示任何包含JavaScript的文件的源代码。
8)Interactive
一个传统风格的调试器的命令行界面。在这个视图中,利用文
本命令几乎可以控制调试器的任何方面。
3. Loaded Script面板
利用此面板可以打开或者是关闭要调试的代码。
4. 断点
在Venkman的各种设置断点的方法中,用鼠标双击左边的空白。
也可以使用命令:
/break file.html 23 设置断点
/fbreak file.html 7 设置未来断点
以上函数都包含二个参数:文件名 行号
可以通过点击断点的设置处来取消断点的设置。
/clear file.html 23 取消断点
调试工具栏的五个按钮。
调试按钮 文本命令
stop /stop
Continue /cont
Step Over /next
Step Into /step
Step Out /finish
分享到:
相关推荐
在 "[Advance] How to debug a program (上)" 和 "(下)" 的示例中,我们可以看到如何通过调试工具逐步定位并解决问题的过程。图片可能展示了断点设置、变量值的观察以及问题解决的步骤。 总的来说,高效的调试技能...
If you want to improve responsiveness or the UX in your ASP.NET applications, JavaScript can be a life saver. In an age where server-side operations have shifted to...See how to test and debug JavaScript
As well as focusing on client-side JavaScript, you will also learn how to work with the Browser Object Model, the Document Object Model (DOM), how to use XML and JSON as well as communicate with ...
As well as focusing on client-side JavaScript, you will also learn how to work with the Browser Object Model, the Document Object Model (DOM), how to use XML and JSON as well as communicate with ...
Unlock the potential of evergreen browsers and increase the efficiency of your ASP.NET applications by learning how to write JavaScriptIf you want to improve responsiveness or the UX in your ASP.NET ...
By the end of the book, you will understand how reactive JavaScript is going to be the new paradigm. What you will learn - Get a run through of the basic JavaScript language constructs - Get familiar...
By the end of the book, you will understand how reactive JavaScript is going to be the new paradigm. What you will learn Get a run through of the basic JavaScript language constructs Get familiar ...
Learn the latest ES6 features and how to test and debug issues with JavaScript code using various modern mechanisms Who This Book Is For JavaScript developers looking to enhance their web developments...
ES6 gives a vast makeover to JavaScript by adding new syntaxes and APIs to write complex applications and libraries that are easier to debug and maintain. ES6 aims to keep JavaScript accessible for ...
ES6 gives a vast makeover to JavaScript by adding new syntaxes and APIs to write complex applications and libraries that are easier to debug and maintain. ES6 aims to keep JavaScript accessible for ...
Through code examples and step-by-step instructions, web developers and frontend engineers familiar with React will learn how to build and style interfaces, use mobile components, and debug and deploy...
You are going to learn how to integrate and use Redux DevTools to debug applications, and access external APIs with Redux. You are also going to get acquainted with writing tests for all elements of ...
Through code examples and step-by-step instructions, web developers and frontend engineers familiar with React will learn how to build and style interfaces, use mobile components, and debug and deploy...
You'll learn all about Closure's Library, Compiler, Templates, testing framework, and Inspector -- including how to minify JavaScript code with the Compiler, and why the combination of the Compiler ...
Test and debug your app on the Web under load with real users, and then submit the finished product to the Android Market This book received valuable community input through O'Reilly's Open ...
Test and debug your app on the Web under load with real users, and then submit the finished product to the Android Market This book received valuable community input through O’Reilly’s Open Feedback...
7. **Silent Failures**: Lists scenarios where JavaScript silently fails or misbehaves, which can be hard to debug. 8. **Numeric Coercion**: Details how JavaScript coerces non-numeric values into ...
Javascript debugging is hard. This book shows you how to resolve the hassle.