Using PhoneGap/Cordova on iOS with external URL

2019-03-10 03:20发布

问题:

I want my phonegap/cordova app to load an external page and nothing local.

Now that i do that , however my plugins (javascript) dont work because they are called from the local index.html.

What do i do in this case? I should put the plugins on my external URL and load them on the external index.html? Also i should also load there the cordova-2.5.0.js ?

And if this is the only way , what happens if i want to load an external page that i dont own the server , but i would like to have push notifications enabled?

How would i enable those plugins?

回答1:

d0nparalias,

Look at this project: https://dl.dropbox.com/u/930742/so/CordovaBrowserSO.zip

As you can see there is no index.html or www/ folder inside.

All files were uploaded to the server and app will download them as needed.

I've accomplished it by doing steps from p.1. from https://stackoverflow.com/a/15319156/753878 answer.

At the server I have all files that you can see in basic www/ folder created with template Cordova project:

All plugins & stuff you include directly in index.html on your server.

If you check config.xml from the archive above you'll see
<content src="http://dymv.comeze.com/www/index.html" />

And the app on launch will say:

Hope it's what you want to reach.
If it's not — please provide more info about result you want to achieve.

BR.
Eugene



回答2:

window.loadURL = function(url){
    navigator.app.loadUrl(url, { openExternal:true });
    return false;
}

to use it in a tag eg

<a href='#' onclick="window.loadUrl('http://google.com'); return false;">open</a>