WebReference.com - Part 1 of chapter 5 from Creating Applications with Mozilla. From O'Reilly (2/6). | WebReference

WebReference.com - Part 1 of chapter 5 from Creating Applications with Mozilla. From O'Reilly (2/6).

To page 1current pageTo page 3To page 4To page 5To page 6
[previous] [next]

Creating Applications with Mozilla, Chapter 5: Scripting Mozilla

JavaScript and the DOM

In the application layer of Mozilla, there is little distinction between a web page and the graphical user interface. Mozilla's implementation of the DOM is fundamentally the same for both XUL and HTML. In both cases, state changes and events are propagated through various DOM calls, meaning that the UI itself is content-not unlike that of a web page. In application development, where the difference between application "chrome" and rendered content is typically big, this uniformity is a significant step forward.

What Is the DOM?

The DOM is an API used to access HTML and XML documents. It does two things for web developers: provides a structural representation of the document and defines the way the structure should be accessed from script. In the Mozilla XPFE framework, this functionality allows you to manipulate the user interface as a structured group of nodes, create new UI and content, and remove elements as needed.

Because it is designed to access arbitrary HTML and XML, the DOM applies not only to XUL, but also to MathML, SVG, and other XML markup. By connecting web pages and XML documents to scripts or programming languages, the DOM is not a particular application, product, or proprietary ordering of web pages. Rather, it is an API-an interface that vendors must implement if their products are to conform to the W3C DOM standard. Mozilla's commitment to standards ensures that its applications and tools do just that.

When you use JavaScript to create new elements in an HTML file or change the attributes of a XUL button, you access an object model in which these structures are organized. This model is the DOM for that document or data. The DOM provides a context for the scripting language to operate in. The specific context for web and XML documents-the top-level window object, the elements that make up a web document, and the data stored in those elements as children-is standardized in several different specifications, the most recent of which is the upcoming DOM Level 3 standard.

The DOM Standards and Mozilla

The DOM specifications are split into different levels overseen by the W3C. Each level provides its own features and Mozilla has varying, but nearly complete, levels of support for each. Currently, Mozilla's support for the DOM can be summarized as follows:

  • DOM Level 1: Excellent

  • DOM Level 2: Good

  • DOM Level 3: Poor; under construction

Mozilla strives to be standards-compliant, but typically reaches full support only when those standards have become recommendations rather than working drafts. Currently, Level 1 and Level 2 are recommendations and Level 3 is a working draft.

Standards like the DOM make Mozilla an especially attractive software development kit (SDK) for web developers. The same layout engine that renders web content also draws the GUI and pushes web development out of the web page into the application chrome. The DOM provides a consistent, unified interface for accessing all the documents you develop, making the content and chrome accessible for easy cross-platform development and deployment.


To page 1current pageTo page 3To page 4To page 5To page 6
[previous] [next]

Created: September 19, 2002
Revised: September 19, 2002

URL: https://webreference.com/programming/javascript/mozillaapps/chap5/1/2.html