Hello,
How can I open a link in external browser? InAppBrowser: false does not work.
Thanks

Comments

coolman7’s picture

Title: How to links in external browser » How to open links in external browser
tyler.frankenstein’s picture

Status: Active » Closed (works as designed)

Please spend some time looking at the Documentation on drupalgap.org, many topics are already covered and won't need a support issue. Here is information on External Links:

http://drupalgap.org/node/524

coolman7’s picture

I added InAppBrowser plugin. Works with a minor issue.

coolman7’s picture

It would be better to have an option to open default browser (like Chrome, Firefox or any other system default browser) instead of InAppBrowser but as far as I searched on internet, it is not so easy.

I want to open Google Play Store page of current app. InAppBrowser gives an error message for market:// type links, but opens Play Store correctly. It works but if I can open default browser, I may not have that error message.

tyler.frankenstein’s picture

Status: Closed (works as designed) » Postponed

Ok, thank you for clarifying. Yes, it is difficult to open in the default browser, I've never gotten it to work.

tyler.frankenstein’s picture

Title: How to open links in external browser » Open links in system browser
Category: Support request » Feature request
Status: Postponed » Needs work

This is possible if you use _system as the target: http://plugins.cordova.io/#/package/org.apache.cordova.inappbrowser

DrupalGap doesn't support this yet, so you'll have to build your link manually, like so:

var html = bl('example.com', null, {
    attributes: {
      onclick: "window.open('http://example.com', '_system', 'location=yes')"
    }
});
coolman7’s picture

Thanks for info.

If the drupalgap code will be changed like this, all the time external (system) browser will be used. Or there could be implemented another option like UseSystemBrowser. If UseSystemBrowser is false, target will be "_blank", if UseSystemBrowser is true, target will be "_system"

line 5547 of drupalgap.js:

        if (variables.options.InAppBrowser) {
          onclick =
            "window.open('" + variables.path + "', '_system', 'location=yes');";
        }
eudaemonia’s picture

I'm using <a href="#" onclick="window.open('web address', '_system');" linked text</a> to get links to open in a system browser and it's working great, but I have to do this manually: I have to open each individual piece of content and edit the html, which isn't feasible on at least one of my apps.

Is there anyway to place a condition in the .js that would apply this automatically to links?

tyler.frankenstein’s picture

I have to open each individual piece of content and edit the html, which isn't feasible on at least one of my apps.

@eudaemonia, please clarify what you mean by this.

eudaemonia’s picture

I have a content type foo that has a body field that more often than not contains one or more html links in the body field. Every time content of the type foo is created (by myself, a user, or an rss feed) if the body field has a link in it, I have to node/edit to apply the code above to each link in the body field.

tyler.frankenstein’s picture

I'd recommend expanding upon the http://drupalgap.org/project/pathfix module, or deriving from it the functionality you desire.