1. Android 4.0.3
2. PhoneGap 2.9.0
1. An existing WWW Web Site
2. PhoneGap application having it's "super.loadUrl" set to the WWW URL ( not local FS )
4. Extended App functionality is executed by the WebSite, eg. specialized video capture Activity usage
When lunching the WebSite as in PhoneGap framework I try to load cordova.js:
( ), Unfortunately, this cause a security exception.
What is the best approach to support the above mentioned use-case ?
Keep in mind that Cordova/PhoneGap was not written to allow you to turn websites into apps - the site will probably look and behave poorly. It's best to use a "mobile first" strategy and design your mobile presence either first or separately from the website. You'll probably be spending a lot of effort redesigning and tweaking your website to work with Cordova when it'd be better to just spend the effort to build the web application from scratch.
If you insist on doing it the way you describe (loading the website immediately by changing the
super.loadURL() - btw, you should not be changing
super.loadURL() but instead changing the
<content src=""> tag in
/res/xml/Config.xml), then you'll probably have to upgrade to the latest Cordova to pick up some fixes that will help you load cordova.js over the wire.
From InAppBrowser documentation:
"NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs."
Maybe you can use an iframe to load your website from a local html document that actually loads cordova.js locally.
See http://stackoverflow.com/a/16660136/3429223 for reference, should it help.
Totally agree with MBillau's answer. Trying to load an external website as a Phonegap/Cordova app is not an orthodox use case, that may arise several security concerns. Best approach is to design specific version for the app.