Using XUL, JavaScript, and CSS

Creating Applications with

David Boswell, Brian King, Ian Oeschger, Pete Collins & Eric Murphy Creating Applications with Mozilla

David Boswell, Brian King, Ian Oeschger, Pete Collins, and Eric Murphy

Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Chapter 2 CHAPTER 2 Getting Started

To help you start creating applications as quickly as possible, this chapter presents two “Hello World” examples that demonstrate the beginning stages of Mozilla appli- cation development. The first example is a simple XUL file that is loaded into the browser window. This example is then expanded on by adding additional features to the XUL file, such as imported stylesheets and JavaScript functions. The second “Hello World” example shows how to turn files like these into packages, which are the modular, bundled sets of files that fit together to make Mozilla applications or new modules for the Mozilla browser. These examples provide a context for discussing the development of Mozilla applica- tions. The first example focuses on creating and editing the basic file types, and the second focuses on the organization and distribution of applications on the Mozilla platform. Simple XUL Example Like all good “Hello World” applications, Example 2-1 shows one of the simplest possible examples of XUL. Although it is small, it demonstrates some important aspects of XUL programming, including the use of event handlers to add behavior and the use of a box to lay out elements properly within the window. This example also provides a context for discussing more general features of the language, such as the file format, the namespace, and some XUL programming conventions.

Example 2-1. Hello xFly