bjorgvin bjorgvin - 1 year ago 61
Javascript Question

can externally loaded website access cordova javascript

I have a website in place and I would like to load it into a webview giving the site a native feel.

Now, this is fairly simple to do using window.location='url' but when the site loads the javascript on the site is not able to access plugin apis. So it seems the site is running within a sandbox... unable to access cordova apis.

Is there a way to provide an externally loaded website access to the cordova apis?

I load my external site using

<content src="http://myurl"/>
in my config.xml

Answer Source

Yes, you can do it. Upload all the cordova.js and plugin files from the project to your server, then in the pages on your server just include it. Be sure to keep them in the same relative folders as they are in the project.

<script type="text/javascript" src="cordova.js"></script>

(Note that I have done this on versions 3 to 5, but not in 6 yet.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download