![]() Download and install a copy of Script Debugger before you carry on. Microsoft give it away for free and you can get it here. The first essential step in debugging your code is getting your hands on a debugger. Knowing how to debug effectively is something you either have or you have to pick up over the years and is well beyond the scope of this article. It's an article to describe the practice of debugging. 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. Debugging JavaScript in Your Applications 13 January 2004 ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |