Sams Teach Yourself JavaScript in 24 Hours Free Open Book

Sams Teach Yourself JavaScript in 24 Hours

Previous Page
Next Page

Planning for the Future

In the history of JavaScript, there has never been such a major change to the language that a great number of scripts written using the older version have stopped working. Nevertheless, many scripts have been crippled by new browser releaseschiefly those that used browser-specific features.

The following sections offer some guidelines you can follow in writing scripts to ensure that the impact of future JavaScript versions and browser releases will be minimal.

Keeping Scripts Compatible

Years ago, Netscape and Microsoft introduced separate and incompatible versions of DHTML (Dynamic HTML), which allowed scripts to modify any element of a page for the first time. Early adopters jumped in to write many scripts, some of which you can still find online today. These scripts made some serious mistakes:

  • Browser detection was used to separately support browsers, or in some cases a specific browser was required.

  • Scripts were written to work around bugs in browsers, or sometimes even take advantage of them.

  • The process of writing scripts often involved trial and error rather than consulting official documentation.

This messy scripting gave DHTMLand JavaScripta bad name among serious programmers. Fortunately, the standardized W3C DOM has now replaced the proprietary browser DHTML features, and it's easier than ever to create scripts the right waybut as time goes by, there will undoubtedly be cutting-edge features that aren't quite standard.

One obvious example is AJAX (Asynchronous JavaScript and XML), which is only now being developed as a standard by the W3C, despite working (in sometimes confusingly different ways) in the major browsers.

There's nothing wrong with using these cutting-edge featuresbut if you do, you should be aware that you're going to need to test the scripts on several different browsers. You should use feature sensing rather than detecting (or expecting) particular browsers. Finally, you should be prepared to do a bit of rewriting when the standard arrives.

Staying HTML Compliant

One trend as browsers advance is that newer browsers tend to do a better job of following the W3C standard for HTMLand, often, relying on it. This means that although a page that uses completely standard HTML will likely work in future browsers, one that uses browser-specific features or workarounds is bound to have problems eventually.

By the Way

In particular, the first release of Netscape 6.0 received many complaints about "breaking" previously working pages. In most cases, the page used bad HTML, and previous browsers happened to handle the error more gracefully.


To avoid these problems, try to use completely valid HTML whenever possible. This means not only using standard tags and attributes, but following certain formatting rules: For example, always using both opening and closing <p> tags, and enclosing numbers for table widths and other parameters in quotation marks.

To be sure your documents follow the HTML standard, see Appendix B, "Tools for JavaScript Developers," for suggested HTML validation programs and services. These will examine your document and point out any areas that do not comply with the HTML standard.

Document Everything

Last but not least, be sure you understand everything your scripts are doing. Document your scripts using comments, and particularly document any statements that might look cryptic or are particularly hard to get working correctly.

If your scripts are properly documented, it will be a much easier process if you have to modify them to be compatible with a future browser, JavaScript, or DOM version.

Did you Know?

See Hour 15 for more tips on future-proofing your scripts by using unobtrusive scripting techniques.


Previous Page
Next Page
Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y]


     Main Menu
Sams Teach Yourself JavaScript in 24 Hours
Table of Contents
Copyright
About the Author
Acknowledgments
Part I: Introducing the Concept of Web scripting and the JavaScript Language
Part II: Learning JavaScript Basics
Part III: Learning More About the DOM
Part IV: Working with Advanced JavaScript Features
Part V: Building Multimedia Applications with JavaScript
Part VI: Creating Complex Scripts
Hour 21. Building JavaScript Drop-Down Menus
Hour 22. Creating a JavaScript Game
Hour 23. Creating JavaScript Applications
Hour 24. Your Future with JavaScript
Learning Advanced JavaScript Techniques
Future Web Technologies
Planning for the Future
Moving on to Other Languages
Summary
Q&A
Quiz Questions
Quiz Answers
Exercises
Part VII: Appendixes
Index


More Books
PHP Hacks
Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
The Koran (Holy Qur'an)
Macromedia Flash 8 Bible
Search Engine Optimization for Dummies
YouTube Traffic
PHP 5 for Dummies
Harry Potter and The Chamber of Secrets
Harry Potter and the Sorcerer's Stone
The Pilgrim's Progress
Wireless Hacks
Flash Hacks. 100 Industrial-Strength Tips & Tools
PayPal Hacks. 100 Industrial-Strength Tips and Tools
Amazon Hacks
Pdf Hacks
The Da Vinci Code
Google Hacks
The Holy Bible
Windows XP For Dummies
Harry Potter and the Half-Blood Prince
Seo Book
Upgrading and Repairing Networks
Macromedia Dreamweaver 8 UNLEASHED
Windows XP Annoyances
Windows XP Hacks
Microsoft Windows XP Power Toolkit
Teach Yourself MS Office In 24Hours
iPod & iTunes Missing Manual
PC Hacks 100 Industrial-Strength Tips and Tools
PC Overclocking, Optimization, and Tuning - 2th Edition
PC Hardware In A Nutshell 3rd Edition
PC Hardware in a Nutshell, 2nd Edition
Upgrading and Repairing PCs
Google for Dummies
MySQL Cookbook
Teach Yourself Macromedia Flash 8 In 24 Hours
PHP CookBook
Sams Teach Yourself JavaScript in 24 Hours
PHP5 Manual
Free Games Paper Airplanes
500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele