arod
arod

Reputation: 14042

in an android app how to open an external link in firefox (or user-chosen browser)

I'm using Phonegap + JQuerymobile to develop an Android app.

I wish to open an external link on an external browser (say Firefox, or Chrome; or let the user choose the browser).

How can I achieve this?

I have tried, without achieving desired results:

<a href="https://mylink.com" data-role="button" onclick="window.open('https://mylink.com', '_system'); return false;">mylink.com</a>

I also use '_blank', but I don't really see the difference.

Thanks.

UPDATE:

I've done some research, but have not found yet an answwer. I've also checked this questions, but they don't seem to solve my problem:

  1. Links don't open in external browser in JQuery Mobile with PhoneGap: attributes _blank and _system don't seem to make a difference in my app
  2. Open External Page in Popup in jQuery Mobile: this is using an HTML popup
  3. Force iOS app opens external links in safari: this is for iOs apps
  4. Opening links in external device browser with Cordova/jQuery-mobile: again the _system parameter, which doesn't show the list of browser for the user to choose from (not it's my default Chrome browser either)
  5. other google searches

Upvotes: 1

Views: 2228

Answers (1)

arod
arod

Reputation: 14042

This did the job: using navigator.app.loadUrl()

full example:

<a href="#null" data-role="button" onclick="navigator.app.loadUrl('https://mylink.com/', { openExternal:true }); return false;" target="_system"></a>

(taken from: Opening an url in a new browser window in Android working with PhoneGap)

Upvotes: 1

Related Questions