This article isn't a lesson in the theory of debugging. You might think I've spoilt the fun of describing how we go about finding the error. JavaScript looks for an object called "total" on the form and can't find it. This is the cause of my "undefined" error. In this example I have called my field "Total" and refered to is as "frm.total" in the code. For those who can't, the most valuable lesson to learn about JavaScript is that it's case-sensitive and this is the cause of endless errors. All it has to do is add the values in the first two fields and place the sum in the third:Ĭan you see my error already? Most of you probably can. Now look at the code I wrote for the onclick event of the button. Take the form below, used for adding two numbers, as an example. Sometimes things are a lot more obscure but I will keep it simple here. Most JavaScript errors turn out to be really simple mistakes. This article aims to describe a way of doing so. It wastes too much time! We need to find the error fast. ![]() Eventually, if you're lucky, you'll discover what was causing the problem. You can use these prompts to tell us the values of certain variables as the code progresses. So what do we do at this point? I sometimes find myself adding alert() boxes at strategic points in the code. The line number includes all lines of JavaScript that happen to be included, as well as blank lines and whatnot. It does provide the line number that the error happened on but trying to find this actual line is not always as easy as you might think. After a while you start to get to know what each one might mean, but for the novice this is all but meaningless. The error message tells us almost nothing. It's not necessarily that it's any harder than the other languages to debug, it's just that Internet Explorer doesn't really help us out. Of all the languages we use on a daily basis as Domino Developers JavaScript has to be the trickiest of them all to debug. Type the variable name or object function that you want to call, and it will be displayed.įigure 9-14 shows an example of the windows available in the Script Debugger.Debugging JavaScript in Your Applications 13 January 2004 As you step through code, you can view variables and their values by using the Command Window. Alternatively, you can select the appropriate icons on the toolbar to step through the code. Once the Script Debugger is started, you can step through code by pressing F8, step over code by pressing Shift+F8, or step out of code by pressing Ctrl+Shift+F8. Scripts that are dynamically loaded in the page through ScriptResource.axd and WebResource.axd don’t present a problem and are directly accessible to step into without any extra effort on your part. The hand icon sets breakpoints, and the hand with a red “X” over it removes breakpoints. You can view all of the scripts used in the page through the Running Documents window and set and remove breakpoints by placing the cursor on the line where you’d like to set (or remove) a breakpoint and then selecting the appropriate icon on the toolbar. ![]() Figure 9-13 shows what the Script Debugger looks like in action. NET 2005, it is very functional and can help identify problems encountered in ASP.NET AJAX applications. While the Script Debugger isn’t as robust as the debugger built into Visual Studio. Once installed, the Script Debugger is automatically triggered when you select View Script Debugger Open (or Break at Next Statement) from the Internet Explorer menu. It can be downloaded from (this URL is, of course, subject to change). The Script Debugger has been around for several years as a stand-alone product that can run on a variety of Microsoft operating systems, including Windows NT 4, Windows 2000, Windows Server 2003, Windows XP, and Windows Vista. NET 2005 but need to debug ASP.NET AJAX pages and associated scripts, the Microsoft Script Debugger can be used to view and debug scripts and step through code line by line. In cases where you don’t have access to Visual Studio. Debugging with Internet Explorer and the Microsoft Script Debugger
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |