使用JavaScript检测Mozilla App安装功能

If you follow me on Twitter, you know I'm riveting super excited about the forthcoming Firefox Marketplace. A marketplace where you can download desktop, tablet, and mobile phone applications based on web technologies, from a host with a record as awesome as Mozilla, is a dream come true. The initial install process is powered via a JavaScript interface within Firefox, and if you can detect if the user's current Firefox install has app capabilities, you can advertise your own app when they come to your website.

如果你按照我的Twitter,你知道我 超级兴奋对即将到来的Firefox的市场 。 一个市场上,您可以从拥有Mozilla如此出色记录的主机上下载基于Web技术的台式机,平板电脑和移动电话应用程序,这是梦想成真。 初始安装过程是通过Firefox中JavaScript接口提供动力的,如果您可以检测用户当前的Firefox安装是否具有应用程序功能,则可以在他们自己的应用程序进入网站时进行广告宣传。

JavaScript (The JavaScript)

Feature detection is the best way to discover if the user's browser can install Firefox Marketplace applications:

功能检测是发现用户浏览器是否可以安装Firefox Marketplace应用程序的最佳方法:


var canInstallMozApp = !!(navigator.mozApps && navigator.mozApps.install);


Marketplace features live within the navigator object under the mozApps property. The install method triggers app installation, so that's ultimately the method whose existence should be checked. If present, the user has app install capabilities and you know you can show a "download our app" advertisement or, if your app manifest is configured properly, you can install the app from your own site!

市场功能位于mozApps属性下的导航器对象中。 install方法触发应用程序安装,因此最终应检查其存在性。 如果存在,则该用户具有应用程序安装功能,并且您知道可以显示“下载我们的应用程序”广告,或者,如果您的应用程序清单配置正确,则可以从自己的站点安装该应用程序!

翻译自: https://davidwalsh.name/mozilla-app

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值