开放网络应用(Open Web app)的JavaScript API是提供安装、客户端管理等功能的程序接口。
Feature availability
这些 JavaScript API目前还不可用。当前已经发布的版本在火狐15以后就过时了。
Mozilla已经实现了一个原型: "dashboard",可以到 myapps.mozillalabs.com 进行测试。
Methods of the API
所有和应用相关的方法都通过navigator.mozApps 对象来访问。有两种方法:
- Installation Functions : 和应用安装或者管理已安装应用相关的方法。
- Management Functions : 和应用的显示、启动、同步等相关的方法。
Installation API (navigator.mozApps.* )
该 installation API来自 window.navigator.mozApps 对象.
Management API (navigator.mozApps.mgmt.* )
该management API是特权API。它要授权访问信任页,也就是所谓的 "dashboards"。该 API的方法运行dashboards管理和运行应用。另外,也提供了账户同步方法。
Objects
下面的JavaScript对象由应用API使用:
- App objects 展现应用。
- DOMRequest 对象由多个方法返回。
- DOMError objects 提示错误。
Old API and the new API
若还在实验老的API, 在2012年3月会过期。 新旧对应如下:
navigator.mozApps.install()This function has a changed signature.navigator.mozApps.amInstalled() 过时Replaced bynavigator.mozApps.getSelf() .navigator.mozApps.getInstalledBy() 过时 Replaced by navigator.mozApps.getInstalled() .navigator.mozApps.mgmt.list() 过时 Replaced by navigator.mozApps.mgmt.getAll() .navigator.mozApps.mgmt.watchUpdates(onupdate) 过时 navigator.mozApps.mgmt.clearWatch(watchId) 过时Both of these replaced by
navigator.mozApps.addEventListener(type, cb) and navigator.mozApps.removeEventListener(type, cb) where type can be either "install" or "uninstall".navigator.mozApps.mgmt.uninstall(origin, [onsuccess], [onerror]) 过时Replaced by app.uninstall() where app is an object returned by getAll() or getInstalled() .版权声明
本文仅代表作者观点,不代表百度立场。
本文系作者授权百度百家发表,未经许可,不得转载。



