Skip to content Skip to sidebar Skip to footer

Phonegap: Loading Remote Html

I'm searching for a way to load remote html's in phonegap android app. I'm using super.loadUrl('file:///android_asset/www/hello.html'); but how to load remote html page?

Solution 1:

it's very simple Venkat,

just load required html page with the http request,

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

or you can load local html file like you did

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

and in hello.html used window.location in onLoad() javascript function to load external html page.

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

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

Post a Comment for "Phonegap: Loading Remote Html"