Detecting Mozilla App Install Capabilities with JavaScript

By  on  

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.

The JavaScript

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

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!

Recent Features

Incredible Demos

  • By
    MooTools PulseFade Plugin

    I was recently driven to create a MooTools plugin that would take an element and fade it to a min from a max for a given number of times. Here's the result of my Moo-foolery. The MooTools JavaScript Options of the class include: min: (defaults to .5) the...

  • By
    Smooth Scrolling with MooTools Fx.SmoothScroll

    I get quite a few support requests for my previous MooTools SmoothScroll article and the issue usually boils down to the fact that SmoothScroll has become Fx.SmoothScroll. Here's a simple usage of Fx.SmoothScroll. The HTML The only HTML requirement for Fx.SmoothScroll is that all named...

Discussion

  1. Alex

    I personally can’t find a use for it even if combined with OpenCl, WebGl in the not-so-distant future.

  2. Nice! Potch has some boilerplate install code. I think it should use this snippet if it doesn’t already.

  3. Nice, first I’ve heard of this. Now to think if an app. :-)

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!