我正在寻找一种加载远程 html 的方法phonegap
安卓应用程序。
我在用着super.loadUrl("file:///android_asset/www/hello.html");
但是如何加载远程html页面呢?
这是非常简单的Venkat,
只需使用 http 请求加载所需的 html 页面,
super.loadUrl("http://www.test.com/test1.html");
或者你可以像你一样加载本地html文件
super.loadUrl("file:///android_asset/www/hello.html");
并在 hello.html 中使用window.location
在 onLoad() javascript 函数中加载外部 html 页面。
<!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 清单文件中设置了互联网权限。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)