Brendan Long
Brendan Long

Reputation: 54242

How to open a link in the default browser on Firefox OS?

I have a Firefox OS app where I want a link to open outside of the application (the link is to a different site, and opening it in-application would make the application unusable without a force-quite). How do I do that?


Related bug report

Upvotes: 5

Views: 639

Answers (2)

rge
rge

Reputation: 106

If you don't want to change all the links in the application, you can use WebActivities, e.g. like this:

/*
 * Open all external links in the browser
 */
$('a[href^=http]').click(function(e){
    e.preventDefault();

    var activity = new MozActivity({
    name: "view",
    data: {
              type: "url",
               url: $(this).attr("href")
          }
    });
 });

Upvotes: 5

Ricardo Panaggio
Ricardo Panaggio

Reputation: 643

Use target="_blank" on the <a> tag:

<a href='http://different.site/' target='_blank'>Different site</a>

Actually, if you send an app with external links without it to the Marketplace, it should be rejected. so watch out :)

Upvotes: 5

Related Questions