我正在寻找一种在phonegap android app中加载远程html的方法.
我正在使用super.loadUrl(“file:///android_asset/www/hello.html”);但是如何加载远程html页面?
解决方法:
这是非常简单的Venkat,
只需使用http请求加载所需的html页面,
super.loadUrl( “http://www.test.com/test1.html”);
super.loadUrl( “文件:///android_asset/www/hello.html”);
并在hello.html中使用了onLoad()javascript函数中的window.location来加载外部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 onl oad="onBodyLoad()">
</body>
</html>
请确保在android清单文件中设置了Internet权限.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。