Install Chrome Store Web Apps with JavaScript

By  on  
Chrome Web Store

Being able to install Firefox OS web apps from any domain, not just the platform app store, is a giant step forward in mobile app marketing and freedom.  Firefox OS allows installing apps from any or all domains, and it just so happens that the Chrome Web Store allows JavaScript-triggered app installation as well.

JavaScript Install Code

The chrome.webstore.install method accepts three parameters, the install URL, the success callback, and the error callback:

/* Chrome installation */
var chromeInstallUrl = "path/to/chrome/app";
chrome.webstore.install(chromeInstallUrl,
function() {
	//  Success!
}, function(err) {
	//  Error :(
});

The code above triggers installation of the Chrome web app at the given location.  The obvious difference from Firefox OS app installation is that callbacks are included in the initial call here, instead of adding adding onsuccess and onerror methods to a resulting install object.

Recent Features

  • By
    Introducing MooTools Templated

    One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating: new Element Madness The first way to create UI-driven...

  • By
    Chris Coyier’s Favorite CodePen Demos

    David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...

Incredible Demos

Discussion

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