Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap 2.5.0, how to open external URL for iPad/iPhone?

I try to open external url like this,

<a href="http://google.com" target="_system" >

and also try with _blank but it's open in same app screen not open in safari browser,

How to resolve..?

like image 931
Wiram Rathod Avatar asked Apr 13 '13 12:04

Wiram Rathod


1 Answers

If you change your links to use the new InAppBrowser syntax, then it's easy to open your URLs either in the system web browser, the InAppBrowser or the actual webview of your app.

This code should open your URL in the system web browser (Safari on iOS):

<a href="#" onclick="var ref = window.open('http://google.com', '_system');">

Changing '_system' to '_blank' will open the URL in the InAppBrowser.

Changing '_system' to '_self' will open the URL in the webview of your app (if the domain is whitelisted) or the InAppBrowser (if the domain is not whitelisted).

Sample Gist: https://gist.github.com/wicketyjarjar/7043336

Note: Cordova/PhoneGap 3.0+ require the InAppBrowser plugin to be installed before this will work.

To install the InAppBrowser plugin (if necessary)...

Using Cordova: cordova plugin add org.apache.cordova.inappbrowser

Using PhoneGap: phonegap local plugin add org.apache.cordova.inappbrowser

like image 156
wicketyjarjar Avatar answered Oct 01 '22 15:10

wicketyjarjar