install - Web APIs 编辑

Summary

Installs one or more XPI files on the local machine.

Method of

InstallTrigger object

Syntax

int install(array XPIlist [, function callBackFunc ] )

Parameters

The install method has the following parameters:

XPIlist
An array of files to be installed (see example below).
callBackFunc
An optional callback function invoked when the installation is complete (see example below).

Firefox 3 note

In Firefox 3 the callback is no longer invoked unless the website performing the installation is whitelisted.

Returns

install returns True if the function succeeded and False if it did not, but these values are not always reliable as a determinant of the success of the operation. To surface detail about the status of the installation, use the optional callback function and its status parameter, as in the example below.

Description

In the example below, a special JavaScript object constructor is used to create an object that can be passed to the install() method. The { } constructor takes a comma-delimited set of label/value pairs. For installations, these pairs are the XPInstall confirm dialog display name and the path of the XPI, respectively.

In the example below, a single installation object is created, but you can use this approach to create multiple installations to pass to a single install.

As with the older startSoftwareUpdate method, XPIs installed with this method must have their own install.js files in which the full installation is defined. In contrast to startSoftwareUpdate, install allows you to do multiple installs with the same trigger and provides a unified user experience for the multiple installs.

Example

function xpinstallCallback(url, status)
{
if (status == 0)
   msg = "XPInstall Test:   PASSED\n";
else
   msg = "XPInstall Test:   FAILED\n";
   dump(msg);
   alert(msg);
}
xpi={'XPInstall Pre-Checkin Test':'pre_checkin.xpi'};
InstallTrigger.install(xpi,xpinstallCallback);

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

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

发布评论

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

词条统计

浏览:82 次

字数:3203

最后编辑:7年前

编辑次数:0 次

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