nsIXULAppInfo 编辑

xpcom/system/nsIXULAppInfo.idlScriptable This interface provides information about the host application. It can be used to distinguish between different Mozilla-based applications. It provides application name, application version, Gecko version and more. 1.0 66 Introduced Gecko 1.8 Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

In XULRunner applications nsIXULAppInfo obtains app-specific information from application.ini.

Implemented by: @mozilla.org/xre/app-info;1. To create an instance, use:

var xulAppInfo = Components.classes["@mozilla.org/xre/app-info;1"]
                 .getService(Components.interfaces.nsIXULAppInfo);

The nsIXULRuntime interface is also implemented by "xre/app-info". It contains advanced information on the xul runtime.

Attributes

AttributeTypeDescription
appBuildIDACStringThe application's build ID/date, for example "2004051604". For XULRunner applications, this will be different than the build ID of the platform. Be careful about which one you want. Read only.
IDACString

The XUL application's UUID. Can be an empty string, if id is not set. Has to be defined for advanced application features such as the extension manager and update service.

This has traditionally been in the form "{AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}" but for new applications a more readable form is encouraged: "appname@vendor.tld". Only the following characters are allowed: a-z A-Z 0-9 - . @ _ { } * Read only.
nameACStringThe name of the application. This must be ASCII, and is normally mixed-case, for example "Firefox", "Thunderbird" or "SeaMonkey". Must not be null or an empty string. Read only.
platformBuildIDACStringThe build ID/date of Gecko and the XULRunner platform. Read only.
platformVersionACStringThe version of Gecko or XULRunner platform, for example "1.8.1.19" or "1.9.3pre". In "Firefox 3.7 alpha 1" the application version is "3.7a1pre" while the platform version is "1.9.3pre" Read only.
vendorACStringThe name of the application vendor. This must be ASCII, and is normally mixed-case, for example "Mozilla". Can be an empty string if vendor is not set. Read only.
versionACStringThe XUL application's version, for example "0.8.0+" or "3.7a1pre". It is different than the version of Gecko or the XULRunner platform. Be careful about which one you want! Can be an empty string, but a valid value is required for XUL applications using the extension manager or update service. Read only.

Example

Display the application and the gecko version in an alert box:

var info = Components.classes["@mozilla.org/xre/app-info;1"]
           .getService(Components.interfaces.nsIXULAppInfo);

alert("Application Version: " + info.version + "\n"
   + "Gecko Version: " + info.platformVersion);

Example

This example here uses nsIXULAppInfo to get the version of the current browser and then compares it: Example - Compare current browser version

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:87 次

字数:5798

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文