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

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

current pageTo page 2To page 3To page 4To page 5To page 6
[next]

Creating Applications with Mozilla, Chapter 5: Scripting Mozilla

Faces of JavaScript in Mozilla

As you have already seen in some examples in this book, the user interface uses JavaScript extensively to create behavior and to glue various widgets together into a coherent whole. When you add code to the event handler of one element to manipulate another-for example, when you update the value of a textbox using a XUL button-you take advantage of this first "level" of scriptability. In this role, JavaScript uses the Document Object Model (DOM) to access parts of the user interface as a hierarchical collection of objects. The section "Adding Scripts to the UI," later in this chapter, discusses this highest level of scripting.

At a second level, JavaScript glues the entire user interface to the XPCOM libraries beneath, which create the application core. At this level, XPConnect (see the section "What Is XPConnect?" later in this chapter) provides a bridge that makes these components "scriptable," which means that they can be invoked from JavaScript and used from the user interface layer. When JavaScript calls methods and gets data from scriptable components, it uses this second layer of scriptability.

Finally, at the third and ultimate level of Mozilla scripting, JavaScript can be used as a "first-order" language for creating the application core itself, for writing software components or libraries whose services are called. We discuss this third level of scripting and provide a long example in the section "Creating a JavaScript XPCOM Component" in Chapter 8.

When you use JavaScript in these contexts, the application architecture looks something like Figure 5-1, in which scripting binds the user interface to the application core through XPConnect and can reside as a software component using such technologies as XPIDL and XPCOM.

Scripting in Mozilla
Figure 5-1: Scripting in Mozilla


current pageTo page 2To page 3To page 4To page 5To page 6
[next]

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

URL: http://webreference.com/programming/javascript/mozillaapps/chap5/1/