1

I am beginner to phonegap. I want to create layout inside index.html which is driven by javascript and also having cordova to use apis in app. I am able to run hard coded index.html but I want to run as a live site inside phonegap and also want to use cordova plugins inside my live site.

Can anybody help me or any idea to how I use live site or dynamic html through javascript?

Thanks in advance,

Vijay Barnwal

2
  • Your question is extremely unclear. Commented Aug 25, 2014 at 13:27
  • Actually I want to add all the js,css files in index.html dynamically through javascript, I want to load my live site inside phonegap using just like window.location and also I can use all plugins of cordova inside my site. Commented Aug 25, 2014 at 13:32

1 Answer 1

2

You can load a live website by any of these 3 methods:

  1. Embed an HTML iframe <iframe src="http://example.com"></iframe>, for this to work, you will need to enable Cross-Origin Resource Sharing on your device and on your web server. Read Cordova 3.5.0 Whitelist Guide and for server, I want to add CORS support to my server.

  2. Use metatag to redirect the user to the desired URL. <meta http-equiv="refresh" content="0; url=http://example.com/" />

  3. If you still need to use all the Cordova functions and plugins, the only way to do it is by loading the website using AJAX into a <div> tag. Read: Ajax/jQuery - Load webpage content into a div on page load? Note: You still need to enable CORS for this to work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.