Reputation: 2596
How do I open external websites inside the webview used by phonegap. If I'm using
window.location.href = "www.example.com"
It will open the browser and load the website instead.
I found https://github.com/phonegap/phonegap-plugins/tree/master/Android/ChildBrowser but this will open a modal with the website.
Upvotes: 1
Views: 1491
Reputation: 1985
In your PhoneGap.plist
add under the ExternalHosts
key: *.example.com
. It's in fact a white list to prevent your application going to non-authorized url, otherwise it will open in the webbrowser which is kind of a sandbox environment.
Anyway I don't think it will work, if you leave the PhoneGap structure by going to an other url, in addition to the whitelist, you should use an iframe to handle external links.
EDIT: for Android open your config.xml file and add the following:
<access origin="*" />
<access origin="http://phonegap.com" subdomains="true" />
You can also check the documentation of this file.
Upvotes: 3