<a target="_blank" data-rel="external" href="http://www.kidzout.com">www.kidzout.com</a>
hey experts i am using phonegap 2.9.0 and i am using the above code to open the link in the browser but it opens it in the same app...... how to open it safari browser?
it opens the website in the same app and then i am unable to come back to the app, so i need to delete the app and install that again.....
With Cordova 5.0 and greater the plugin InAppBrowser is renamed in the Cordova plugin registry, so you should install it using
Then use
There are 2 different ways to open URL in android and iphone.
FOR IOS use following code.
and for android OS use following code.
None of these answers are explicit enough to get external links to open in each platform. As per the inAppBrowser docs:
Install
Overwrite window.open (optional, but recommended for simplicity)
If you don't overwrite
window.open
, you will be using the nativewindow.open
function, and can't expect to get the same results cross-platform.Use it to open links in default browser
Note that the target for the inAppBrowser (which is what the plugin name suggests it is to be used for) is
'_blank'
, instead of'_system'
.Without the steps above, I was not able to get links to open in the default browser app cross-platform.
Extra credit
Here's an example (live) click handler for the links:
As answered in other posts, you have two different options for different platforms. What I do is:
So as you can see I am checking the device platform and depending on that I am using a different method. In case of a standard browser, I leave standard behaviour. From now on the solution will work fine on Android, iOS and in a browser, while HTML page won't be changed, so that it can have URLs represented as standard anchor
The solution requires InAppBrowser and Device plugins
At last this post helps me on iOS: http://www.excellentwebworld.com/phonegap-open-a-link-in-safari-or-external-browser/.
While using
navigator.app.loadUrl("http://google.com", {openExternal : true});
for Android is OK.Via Cordova 3.3.0.
I'm using PhoneGap Build (v3.4.0), with focus on iOS, and I needed to have this entry in my config.xml for PhoneGap to recognize the InAppBrowser plug-in.
After that, using window.open(url, target) should work as expected, as documented here.