- The "Contact Us" Form
- Part 1: JavaScript Debugger Basics
- Part 2: Debugging Logic Errors
- Part 3: Limitations of the JavaScript Debugger
- Part 4: Balancing Braces
Part 3: Limitations of the JavaScript Debugger
Dreamweaver's JavaScript Debugger is an excellent tool, but it does have some limitations. To illustrate, let's remove an ending curly brace from a block of code and see what happens.
In Dreamweaver's Code view, remove the ending curly brace on line 28, which is highlighted in Figure 16.
Figure 16 Removing the curly brace to illustrate limitations in the Debugger.
Now run the JavaScript Debugger again by pressing Alt+F12. Dreamweaver's JavaScript Debugger correctly identifies that a syntax error exists, but it identifies the position incorrectly, as shown in Figure 17.
Figure 17 The JavaScript Debugger does not locate every error possible.
Ideally, the JavaScript Debugger would display a more accurate syntax error message, such as "missing closing curly brace for if statement beginning on line 25." Unfortunately, the JavaScript Debugger isn't savvy enough to understand exactly what you're trying to accomplish with the code. So, the Debugger counts the number of opening braces and closing braces and sees that you're missing one, so it assumes that you need to add more code right before the end of the script (</script>)
Fortunately, Dreamweaver has a feature called Balance Braces that can help you solve this problem.