The Alert() function is your most useful tool for debugging errant scripts.
For example:
Alert("About to send the enter key"); Alert("The value of x is " + x.toString()); Alert("The customer number is " + objGlobal.CustomerNumber);
Strange behavior in scripts
Object expected