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

  • By
    39 Shirts – Leaving Mozilla

    In 2001 I had just graduated from a small town high school and headed off to a small town college. I found myself in the quaint computer lab where the substandard computers featured two browsers: Internet Explorer and Mozilla. It was this lab where I fell...

  • By
    Vibration API

    Many of the new APIs provided to us by browser vendors are more targeted toward the mobile user than the desktop user.  One of those simple APIs the Vibration API.  The Vibration API allows developers to direct the device, using JavaScript, to vibrate in...

Incredible Demos

  • By
    Vibration API

    Many of the new APIs provided to us by browser vendors are more targeted toward the mobile user than the desktop user.  One of those simple APIs the Vibration API.  The Vibration API allows developers to direct the device, using JavaScript, to vibrate in...

  • By
    Implement the Google AJAX Search API

    Let's be honest...WordPress' search functionality isn't great. Let's be more honest...no search functionality is better than Google's. Luckily for us, Google provides an awesome method by which we can use their search for our own site: the Google AJAX Search API.

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!