PhoneGap的:加载远程HTML [英] phonegap: loading remote html
问题描述
我在寻找一种方式来加载远程HTML在的PhoneGap
Android应用程序。
我使用 super.loadUrl?(文件:///android_asset/www/hello.html);
但是如何加载远程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?
推荐答案
这是非常简单的Venkat在,
it's very simple Venkat,
只加载所需的HTML页面的HTTP请求,
just load required html page with the http request,
super.loadUrl(http://www.test.com/test1.html);
或者像你一样,你可以加载本地的html文件
or you can load local html file like you did
super.loadUrl(文件:///android_asset/www/hello.html);
和中的onLoad(使用 window.location的
hello.html的)JavaScript函数来加载外部HTML页面。
and in hello.html used window.location
in onLoad() javascript function to load 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>
请确保您设置的Android清单文件中的Internet权限。
Please make sure you set the internet permission in android manifest file.
这篇关于PhoneGap的:加载远程HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!