Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap open external links outside App from a Whitelist URL

I'm using Phonegap 2.3 and I'm considering updating to the newer library. I think this might be a problem that was fixed with the newer library.

Anyway I have tried:

window.open('http://google.com','_blank')

window.location = "http://google.com";

Both had no luck forcing the user to load the external link in safari.

I also ready about targeting _system which didn't work either.

like image 685
JAppleseed Avatar asked Jun 03 '13 19:06

JAppleseed


2 Answers

There is a config.xml setting that will do the trick:

<preference name="stay-in-webview" value="true" />

Or, you can use _system if you include the InAppBrowser plugin.

<a href="#" onclick="window.open('http://www.nhl.com', '_system', 'location=yes');">_system</a>

InAppBrowser API Doc

Here's a couple related threads:

https://build.phonegap.com/docs/config-xml (page search for "stay-in-webview")

PhoneGap Build: how to open external url in device browser on Android?

like image 87
ezekielDFM Avatar answered Sep 28 '22 04:09

ezekielDFM


For Phonegap 3 you have to install the InAppBrowser plugin and then do:

window.open("http://google.com", "_system");
like image 29
jackocnr Avatar answered Sep 28 '22 02:09

jackocnr