home | software | javascripts | debug javascript
Unlike programming languages that have console output or IDE debug traces, Javascript can be complex to debug. The Firebug utility in Firefox is helpful, though sometimes not enough. Filling your code with 'alert(...)' methods interrupts the program's execution and can be unusable in repetitive loops.
To enable debug output, place this in your page:
Alternatively, call this method from elsewhere in your Javascript code.
Other methods you can call are:
writeDebug(message) - writes the object's string value as a linewriteEval("a.b.c") - writes the result of executing the specified statement (must be a globally eval-able statement)writeDebugObject(obj) - enumerates all properties of an object and writes each on its own lineclearDebug() - clears the contents of the div (can also be called by the user clicking the 'clear' link)Debugging is enabled on this page. Try it out:
debug.js - right-click and choose save as