|Joined: 28 Jul 2004
|Total Posts: 15
Posted: 30 Jul 2004 11:30 AM
2. How do you read, write, delete and detect support for cookies?
3. What are the limits on cookies?
5. How do I format a number so that it always has two decimals?
6. How do I trim whitespace from the beginning and end of a string?
7. Why does parseInt('08') generate 0?
8. How do I read/write files?
9. How do I get multiple scripts to work on a single page?
10. How do I convert a decimal number to hexadecimal, and the other way around?
11. How do I add ordinals (st, nd, rd, th) to a number?
14. How do I shorten my lengthly if() statements?
Mozilla. This in general covers both Mozilla and Mozilla Firebird, and often also includes other Mozilla based browsers such as K-Melon, Galeon, Camino. <http://mozilla.org/products/>, Any platform.
Microsoft Internet Explorer in general. n stands for version number.
Microsoft Internet Explorer for Windows. http://www.microsoft.com/windows/ie/default.asp, Windows
Microsoft Internet Explorer for Mac. http://www.microsoft.com/mac/produc...nternetexplorer, Mac
Apple Safari (based on KHTML and KJS by KDE) http://www.apple.com/safari/, Mac OS X
KDE Konqueror. http://www.konqueror.org/, X11
Opera. Normally we're talking about version 7 on Windows and Linux, but we may be talking about version 6 for the Mac. <a href="http://www.opera.com/download/'>http://www.opera.com/download/</a>, Windows, Linux, (Mac).
Netscape6, Netscape7. Netscape browser based on Mozilla.
Netscape Navigator. Netscape browsers up to version 4.x.
Netscape Communicator. Same as nn4.x.
The most common is to insert alerts into the code, where you alert the values and types of variables, function arguments, and object properties. If you are doing code forking to support different ways of doing things, you may use confirms to force a certain path to be taken. If you want to be able to cut and paste the results, you may want to use prompts.
In an effort to get better error reporting you may use window.onerror or the try..catch statement. These may also be used to let code run without halting on errors, letting all errors be reported after the code has been executed.
Reduce hard-to-find errors that may sneak into your code by always following coding conventions such as explicitly ending statements by semicolon instead of relying on the semicolon insertion; by always using braces around the bodies of statements of the control structures (if, if..else, switch, while, do..while, for, for..in statements); by using parentheses instead of relying on operator precedence; by using consistent and verbose naming conventions; by using indentation and spacing consistently in a way that makes your source code easily readable; by avoiding automatic type casting through using explicit type casting or other methods to achieve the same effect; by using full syntaces where browsers allow shortcuts (this especially goes for ie), etc.
Run the code through js lint, which will do some work towards detecting potential coding errors.
Ok, that was what you could do in the code itself. How about the detection of errors in the code?
Use many browsers for testing your scripts while you develop them. On windows, use at least ie6w, op7 and moz. On mac, use at least saf, op7, ie5m and moz. If things doesn't work in one or more of these browsers, see if you can do them differently. If not, make a fork for the chosen browser.
In ie, be sure to turn error reporting on. If you're on windows, use the Microsoft Script Debugger. You may use the debugger keyword inside the script to turn control of the execution of the script over to the debugger, if you need to track an error down. It's recommended that you use ie primarily for testing, and use op7 or moz for debugging.
In konq your are pretty much on your own. Use the source code tricks.
In saf you can turn on the hidden debug menu, to display frighteningly unhelpful error messages in the system Console, as well as get access to a more useful Show DOM Tree feature, if you turn on display of the Debug menu using the following command in the terminal while Safari is not running:
defaults write com.apple.Safari IncludeDebugMenu 1