user2765683 user2765683 - 4 months ago 49x
iOS Question

Cordova/Phonegap load external site in main Cordova webview

What i want

I have external web-resource that i want cordova webview to simple open and be able to navigate through its inner navigation.


InAppBrowser docs said

The InAppBrowser window behaves like a standard web browser, and can't
access Cordova APIs. For this reason, the InAppBrowser is recommended
if you need to load third-party (untrusted) content, instead of
loading that into the main Cordova webview

So i have an trusted external links (let's say i want to load in main webview and want to control its process though window.location.href or user links click.

What i tried

Generated hello world app with latest cordova and inserted

window.location.href = ''

to its onDeviceReady. It's config was already having (and i tried to change it to concrete adress)

<access origin="*" />

I also tried and manual user link clicks, but all i've got is dialog to open link in external browser instead of rendering it inside same webview.
I also tried InAppBrowser extension, that works fine when i disable navigation bar but it has communication problems and doesn't work on manual link licks and window.location.href changes.


Solved this issue using following rules on both ios and android:

<access origin="*" />
<allow-navigation href="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="tel:*" />
<allow-navigation href="sms:*" />
<allow-navigation href="mailto:*" />
<allow-navigation href="geo:*" />

If you stuck on same problem you also need to know following: