MegaAppBear
MegaAppBear

Reputation: 1220

Load remote index.html with Cordova

I want to render a remote HTML page when my Cordova app starts, instead of "./index.html"

Tried this in config.xml

<content src="http://example.com/index.html" />
<access origin="*" />

And also tried placing this into ./index.html

window.location.href = 'http://example.com/index.html';

Both load a blank white screen when I start the app. Got no errors in the device log. Using Cordova version 5.3.3.

Any ideas?

Upvotes: 2

Views: 1811

Answers (3)

justin
justin

Reputation: 3607

You can change the loadUrl statement in the native code e.g. in Android, you need to find MainActivity.java under platforms/android/src....

I myself am currently looking for a way to do this from index.html (to display for e.g. a loading screen / error message in case of network issues).

I believe I had tried using window.location.href but that simply opened the browser to the specified URL. I want it to open up in the app's WebView of course.

Upvotes: 0

jcarrera
jcarrera

Reputation: 1068

If you want to use <access origin="*" /> you need to add this meta tag to your html page(s) in your cordova app:

<meta http-equiv="Content-Security-Policy" content="*">

I hope this helps you!

Upvotes: 1

Chetan Hirapara
Chetan Hirapara

Reputation: 694

In your index.html page, you can write windows.onload() function inside this write redirect to this http://example.com/index.html

Upvotes: 0

Related Questions