Join MDN and developers like you at Mozilla's View Source conference, November 2-4 in Portland, Oregon. Learn more at

아직 자원 봉사자들이 한국어로 현재 문서를 번역하지 않았습니다. 가입해서 이 문서가 번역되는 일에 함께 해 주세요!


Starting with Mozilla/XULRunner 1.8, there now is a way to find out which application, application version, and Gecko version your code is running on.

This is useful, for example, for extensions that support several Mozilla-based applications or several versions of a single application. This is not useful for scripts on webpages, which should continue using the navigator object when it's not possible to rely on feature-detection.

nsIXULAppInfo interface

To distinguish between different Mozilla-based applications, use the frozen nsIXULAppInfo interface. The following sections provide a few examples of using nsIXULAppInfo from JavaScript.

Note that while Firefox 1.5, Thunderbird 1.5, and XULRunner 1.8-based applications support nsIXULAppInfo, older applications, such as Firefox and Thunderbird 1.0, do not support it. You'll need to have additional code for those older versions.

Getting nsIXULAppInfo

To get a component implementing nsIXULAppInfo use this code:

var appInfo = Components.classes[";1"]

(For explanation see this Creating XPCOM article.)

Getting application information

After you obtained the app info component, you can read its properties to get the application's ID, human-readable name, version, platform version, etc. For complete list of nsIXULAppInfo's properties, please see nsIXULAppInfo interface description.


You can tell which application you're running under using the nsIXULAppInfo.ID property.

const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
const THUNDERBIRD_ID = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
const SEAMONKEY_ID = "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}";
var appInfo = Components.classes[";1"]
if(appInfo.ID == FIREFOX_ID) {
  // running under Firefox
} else if(appInfo.ID == THUNDERBIRD_ID) {
  // running under Thunderbird
} else if(appInfo.ID == SEAMONKEY_ID) {
  // running under SeaMonkey
} else {
  // another app

Note: you could also use, which is a human-readable name for the application, such as "Firefox", "Thunderbird" or "SeaMonkey", but who knows, maybe they'll rename it again!


Sometimes you need to know the version of the application your code is running under. For example, one of unfrozen functions you're relying on was changed.

Note: nsIXULAppInfo provides information about the application and the platform, be careful to use the right one, especially when dealing with XULRunner-based applications.

In such cases, you probably want to check nsIXULAppInfo.version and/or nsIXULAppInfo.appBuildID. The latter is useful if you're trying to support nightly development builds of the application, and the former can be useful if you only support official releases, and to distinguish between branch and trunk builds.

Example 1: checking Firefox version

// assuming we're running under Firefox
var appInfo = Components.classes[";1"]
var versionChecker = Components.classes[";1"]
if(, "1.5") >= 0) {
  // running under Firefox 1.5 or later

See nsIVersionComparator for details

Example 2: dealing with nightlies

var appInfo = Components.classes[";1"]
if(appInfo.appBuildID >= "2005093006") {
  // running on a build after 2005093006

You shouldn't rely on build IDs for releases, as build ID might be different for custom build or a localized version of an application.

Platform version

nsIXULAppInfo provides version information about both the XUL application (such as Firefox) and the platform (i.e. Gecko or XULRunner). For example, in Firefox 1.5 beta 2 application version is 1.4.1 and platform version is 1.8b5. Be careful to use the information you need, especially when dealing with XULRunner-based applications.

Obtaining platform version information is done like this:

var appInfo = Components.classes[";1"]
var platformVer = appInfo.platformVersion;
var platformBuildID = appInfo.platformBuildID;

Getting nsIXULAppInfo in xpcshell tests

In Firefox 21, a testing module was added that provides access to app info during the execution of xpcshell tests. See Bug 809920, and in summary:

// Work around the fact that xpcshell doesn't have a proper app-info XPCOM object.

Older versions

As stated above, older Mozilla 1.7-based applications do not support nsIXULAppInfo. You'll have to write additional code if you choose to support those versions.

For example, Firefox and Thunderbird 1.0 stored their ID in the preference (and their version in app.version), so you could use code like this to find out what application you're running under:

function getAppID() {
  var id;
  if(";1" in Components.classes) {
    // running under Mozilla 1.8 or later
    id = Components.classes[";1"]
  } else {
    try {
      id = Components.classes[";1"]
    } catch(e) {
      // very old version
  return id;

See also

문서 태그 및 공헌자

최종 변경: mnoorenberghe,