Welcome to the XUL School Tutorial!

    欢迎来到XUL School 指南

    This tutorial is meant to be the stepping stone that will turn you into a professional Firefox extension developer in no time. We have poured years of XUL experience into it, providing many solutions for problems extension developers commonly run into.

    这个指南意欲在最短的时间内让你成为一个专业的 Firefox extension 的开发者. 我们倾注多年 XUL 编程经验, 只为你在开发 extension 中少走弯路.

    XUL School was created by Appcoast (formerly Glaxstar), one of the few companies dedicated to building high-quality Firefox extensions. A team of over a dozen XUL developers conformed Glaxstar at the time this tutorial was created, and the combined experiences of years creating Firefox extensions are reflected here.

    XUL School 是由 Appcoast(前身是 Glaxstar)来编写的, 它是全身心专注高品质 Firefox extensions 的为数不多的公司之一. 在这个指南创建时, 它还是一个由12个XUL 开发者组成的 Glaxstart 的团队, 多年综合的 firefox extension 编写经验也奉献于此.

    With this tutorial you'll learn how to develop Firefox extensions. You'll learn how to quickly do the most common tasks in extension development, comparing several different approaches to solve them. In most cases we'll provide code samples that you can easily copy and adapt to your needs, as well as some working example extensions. The tutorial aims to be as brief as possible, often falling back on Mozilla documentation for more detailed information. You can think of it as a quick guide to the expansive world that is the Mozilla platform. Most links in this documentation are meant to be clicked and read.

    在这个指南中你将会学到如何开发Firefox extensions, 你会学到, 相比较于多种不同的方法, 如何快速地完成extension 开发过程中的最常见的任务. 在多数情况下我们会提供代码示例, 你可以很简单的拷贝及修改至你所需要的. 同时我们也提供一个示例的 extensions. 这个指南的目标是越精炼越好, 所以为了得到更多的信息, 你需要经常查看Mozilla 参考文档. 你可以把它当成一个 Mozilla 大舞台的快速入门指南. 文章中的多数链接是可以点击查看的.

    We'll start with a brief introduction to some key concepts, in case you're not familiar with Mozilla and Firefox.

    我们从一些关键概念开始一个简短的介绍,  万一你对 Mozilla 及 Firefox 不是很了解.

    Mozilla and Firefox

    The term Mozilla can be used to refer to several concepts: the Mozilla project, the Mozilla Foundation, the Mozilla Corporation and the old Mozilla browser. Even Firefox is sometimes referred to as "Mozilla". If you're unfamiliar with these terms, it's good that you take some time and learn a little about Mozilla. This will help you understand the culture that surrounds the Mozilla community.

    Mozilla has spawned several products and projects, the most notable being the Mozilla Firefox web browser. Firefox is one of the most successful open source projects in history, combining the openness, standards-compliance and sophistication of open source with the focus on user experience and powerful outreach more commonly seen in less open companies.

    Version 1.0 of Firefox was released in November 2004, version 2.0 in October 2006, and version 3.0 in June 2008. This tutorial was written after Firefox 3 was released, and has been updated with time. While most of it should still work for creating extensions Firefox 3 (and even Firefox 2), it is strongly recommended that you aim to support modern Firefox versions, to encourage users to stay up to date with security fixes. A release that is more than 6 months old is likely vulnerable to published security bugs.


    XUL (pronounced "zool") is one of many technologies used for creating Mozilla-based products and extensions. It is only one part of the development landscape, but given that it's practically exclusive to Mozilla, it tends to be used to identify all Mozilla-related development. You'll sometimes read terms like "XUL applications" and "XUL extensions", but rarely will they refer to projects that are exclusively built with XUL. It usually means that the projects were built using Mozilla technologies. Even this project, called XUL School, covers several other technologies such as JavaScript, CSS, XBL and XPCOM.


    The Gecko engine is the part of Firefox used to render web pages and its own user interface. You can identify the level of compatibility of web standards in Gecko-based browsers looking at their User Agent string, which should include the Gecko version. Gecko versions are somewhat independent from Firefox versions, and you can see a mapping of Firefox versions and Gecko versions at the Gecko page. The User Agent String for Firefox at the time of this writing (in US English, Mac OS X) is:

    Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1

    The highlighted section is the Gecko version: 7.0.1. You can read and copy the user agent string of any Firefox window, choosing "Help > Troubleshooting Information" from the main menu.


    Firefox and other Mozilla applications can be seen as composed of two different parts: a user interface layer that is distinct for each project, and a common platform on top of which the interface layer is built. This platform is known as XULRunner. XULRunner includes the Gecko rendering engine, the Necko networking library, and several other components that provide OS-independent file management, accessibility, and localization, among others. It is this very powerful platform that has allowed such a fast growth of the development community surrounding Mozilla and Firefox.

    XULRunner is available in binary form at the XULRunner page, and it is the base for several projects, such as Songbird, Miro and Eudora. There's a very comprehensive list of XULRunner applications in the XULRunner Hall of Fame.

    On to the Tutorial

    With the basic concepts out of the way, we can now get right into extension development. You are probably still wondering what exactly is an extension, what can it do, and how can you make them. Well, this whole tutorial is devoted to explaining that to you.

    Welcome to the world of extension development. Now let's get to it.

    This tutorial was kindly donated to Mozilla by Appcoast.



    此页面的贡献者有: ziyunfei,
    最后编辑者: ziyunfei,