Web DevCenter
oreilly.comSafari Books Online.Conferences.
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA

Sponsored Developer Resources

Web Columns
Adobe GoLive
Essential JavaScript

Web Topics
All Articles
Scripting Languages

Atom 1.0 Feed RSS 1.0 Feed RSS 2.0 Feed

Learning Lab

Essential JavaScript

Yajc -- Yet Another JavaScript Column


Also in Essential JavaScript:

Extending Dreamweaver: Let Dreamweaver Create Your Menus

Extending Dreamweaver with its JavaScript API

Accessing Dreamweaver's JavaScript API

Creating Themes with CSS and JavaScript

Parsing and DOM-Tree Building With JavaScript

JavaScript really hasn't been in the news much lately. In fact, most people didn't even recognize that it's now actually called ECMAScript since it has been standardized by the ECMA in ECMA-262.

That being said ... what would the Web be without JavaScript? No chance of getting annoyed by rollover buttons that are used solely to prove their existence. No way of having your browser crashed by dozens of windows popping up at the same time. Indeed those are annoying features, most of them created with our friend JavaScript. But this language has many good, useful things to offer too. And that's why I'm asking for your attention.

Probably by now you're thinking, "Hasn't everything been discussed and explained so far?"

The answer is definitely no. On one hand, it's true, many things have been said, but the Web has changed a great deal since those earlier discussions. As a result, I think it's time to reevaluate the power of JavaScript and its accompanying languages and tools.

Related Reading

JavaScript: The Definitive Guide, 4th EditionJavaScript: The Definitive Guide, 4th Edition
By David Flanagan
Table of Contents
Sample Chapter
Full Description

JavaScript survives DHTML

One of the last big hypes around JavaScript was Dynamic HTML -- actually a buzzword describing a handful of some new, more or less working features of the 4.x platforms and JavaScript 1.2 -- allowing access and modification of documents at run-time. But if you look at the Web today, you won't find a lot of dynamic documents -- in most cases, only dynamically created hierarchic menus survived the hype. It's not hard to tell why: Most times it would just take too much time (and money) to create a cool solution that runs on all platforms.

The greatest problem is the differences in the various document object models supported by the major platforms. A common document object model for all platforms is the Web's next step we're all craving, because it eliminates the need to provide customized solutions for every platform supported, thus bringing the Web back to its conceptual roots. Mozilla's efforts and Netscape's release of Netscape 6 closed the gap to the competitor Internet Explorer 5.x; at least the major browsing platforms are now capable of the W3C Document Object Model (DOM), which, in combination with JavaScript, opens new ways of document presentation and manipulation and sends existing DHTML solutions to retirement.

But, the present situation is not as bright as described above. New technologies do contain new traps, and DOM support on both platforms is different and contains quite a few bugs and inconsistencies.

But not only has the technology around JavaScript evolved, JavaScript itself is heading towards version 2. The actual version 1.5 comes with a bunch of new features that make it a more serious programming language, and it contains a lot to talk about. Not limited to run only in a browser any longer, JavaScript is also used as a scripting language in many applications, like Macromedia's Dreamweaver and Fireworks.

The focus of this ongoing column

This column will concentrate on the new client-side technologies available and will discuss ways to take advantage of them. We'll talk about the big picture of our solutions and applications and dive into the details only when necessary, to point out bugs, for example.

Every solution covered will become a part of the O'Reilly JavaScript library, to be launched a week from today, which will grow together with our column. The library will be published under GPL license, so you're free to use it in your own projects. Every item of the library will contain an explanation on how to use the scripts.

Today's menu - extending HTML forms

So where do we begin? How about with one of the most annoying tasks in today's Web client programming: the validation of forms.

Pretty boring, you say. Well, it could be, but this time it's not. I picked this as our starting point, since it's a well-known topic -- doing it the old-fashioned way, at least.

I won't be explaining how to access an element and its values, or how to connect an event to an event-handling function for the thousandth time. Instead, I'll create a solution which completely hides all scripting tasks behind a set of new attributes, called the Forms Extension Framework (ForX).

These attributes describe the elements rather than defining how to do something. Most people find this easier to learn and remember, as this is a more natural way to work with elements, especially for non-programmers.

The application itself does not contain any JavaScript magic, but serves as a good example of how to take advantage of the DOM. Our solution will run on both Netscape 6/Mozilla and IE 5.x.

So, before we dive into ForX head first, let's talk about forms a bit in the accompanying article, Working With Forms: An Introduction.

Claus Augusti is O'Reilly Network's JavaScript editor.

Read more Essential JavaScript columns.

Return to the JavaScript DevCenter.