Feb 5, 2015

Use MozActivity to launch a page

In Firefox OS, you can use MozActivity to launch browser with a specific URL like this:
 
var url = 'http://mozilla.org';
new MozActivity({
  name: 'view',
  data: { type: 'url', url: url }
});

We can listen the event 'appterminated' to know when the browser is killed, and e.detail.origin can tell you which browser is.
 
window.addEventListener('appterminated', function (e) {
  if (e.detail.origin === url) {
    console.log('Ooh, it's killed.');
  }
});

You may want to know,will e.detail.origin be changed if we change the url during browsing the page?
The answer is NO.

Even you browse the page from mozilla.org to www.yahoo.com , e.detail.origin still won't be change.