Phonegap: downloading remote html

I am looking for a way to download remote html to an phonegapandroid application . I use super.loadUrl("file:///android_asset/www/hello.html");, but how to load a remote html page?

+3
source share
1 answer

it's very simple venkat,

just load the required html page with the http request,

super.loadUrl("http://www.test.com/test1.html");

or you can upload a local html file as you did

super.loadUrl("file:///android_asset/www/hello.html");

and in hello.html it is used window.locationin the onLoad () function of javascript to load an external html page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <!-- Change this if you want to allow scaling -->
    <meta name="viewport" content="width=default-width; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>LoadUrl
    <script type="text/javascript" charset="utf-8">
    function onBodyLoad()
    {
        document.addEventListener("deviceready",onDeviceReady,false);
    }
    /* When this function is called, PhoneGap has been initialized and is ready to roll */
    function onDeviceReady()
    {
    // do your thing!
      window.location="http://170.60.26.20:8099/Sencha/Html/index.html";
    }
    </script>
  </head>
  <body onload="onBodyLoad()">   
  </body>
</html>

Please make sure you set the internet permission in the Android manifest file.

+7
source

All Articles