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

user1903724
  • 239
  • 2
  • 11
  • Your question is extremely unclear. – JRulle Aug 25 '14 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. – user1903724 Aug 25 '14 at 13:32

1 Answers1

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.

Community
  • 1
  • 1
James Wong
  • 4,529
  • 4
  • 48
  • 65