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
    JavaScript Promise API

    While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready?  Promises are becoming a big part of the JavaScript world...

  • By
    Interview with a Pornhub Web Developer

    Regardless of your stance on pornography, it would be impossible to deny the massive impact the adult website industry has had on pushing the web forward. From pushing the browser's video limits to pushing ads through WebSocket so ad blockers don't detect them, you have...

Incredible Demos

  • By
    Full Width Textareas

    Working with textarea widths can be painful if you want the textarea to span 100% width.  Why painful?  Because if the textarea's containing element has padding, your "width:100%" textarea will likely stretch outside of the parent container -- a frustrating prospect to say the least.  Luckily...

  • By
    PHP / MooTools 1.2 Accordion Helper

    The MooTools Accordion plugin seems to be the plugin that people seem to have the most problems with. It's an awesome plugin, so I can see why so many people want to use it, but I think that may be part of the problem.

Discussion

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