JavaScripting Netscape 6: No More Sloppy Code | 6
[previous] |
Summary
Scripting for NS6 and IE5.5 takes special care to adhere to standards and good programming practices. Each browser acts differently for external scripts, and you must be careful to encapsulate your element-dependent executable within functions called onload. Netscape 6 is particularly sensitive to improperly nested HTML when executing dynamically loaded scripts. By following these best coding practices, and coding for the DOM, you can ensure your scripts will work for current and future generations of browsers.
Steps for supporting NS6 with your HTML+CSS+JavaScript
- Properly Nest all HTML Tags
- Properly Close all HTML Tags
- Validate your HTML
- Validate your CSS
- Choose the appropriate DOCTYPE, if any
- Encapsulate element-dependent JavaScript within onload functions
- Define onload handers within external files, or subsequent SCRIPT blocks
We've provided some test cases to illustrate the problems that we discussed, and also some workarounds.
Further Reading
- DOCTYPE
- XHTML 1.0: Where XML and HTML meet - Techniques for well-formed XHTML
- HTML 101: Back to Basics - Contains introduction to DOCTYPE
- SGML: Meet your Maker - DOCTYPE intro from HTML with Style
- Hier Menus DOCTYPE Info - From DHTML Lab
- Netscape 6 and JavaScript
- Mozilla.org - Look for bugzilla
- Gecko Connection - Standards-based info and tutorials
- JavaScript Browser Sniffer - Updated for NS6, from WebReference.com
- JavaScript Documentation - From Netscape
- Loading External JS Files for DHTML Browsers - From DHTMLab
- Netscape 6 Tips - From Doc JavaScript
- Netscape 6 Part I: Detection & Scripting
- NS6 Scripting Info - Tutorials plus rated NS6/DOM links
- Scott Andrew - Excellent source for DOM-NS6 scripting info, with detailed tutorials
- Transitioning from Proprietary DOMs and Markup to W3C Standards - By Eric Krock
- W3C Spec's/Validation/Standards
# # #
About the author: Andrew B. King is the founder and Managing Editor of WebReference.com. He holds a BSME and MSME from the University of Michigan. He's been creating Web sites since 1993 and still can't find time for his own home page. He has written for Web Techniques, MacWEEK, and contributed to HTML and Web Publishing Secrets, by Jim Heid. Special thanks go to Dan Ragle of internet.com and Bob Clary of Netscape for their help in researching this article. Andy can be reached at [email protected].
[previous] |
Created: February 15, 2001
Revised: Mar. 6, 2001