【发布时间】:2012-10-13 18:32:41
【问题描述】:
我正在使用 PHonegap 构建服务为一个将显示 flash 的机器人创建一个简单的包装器,然后启动到该网站的移动版本。
我尝试了各种组合,到目前为止,以下组合效果最好:
<!doctype html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
<title>My App</title>
<link rel="stylesheet" href="assets/css/master.css" type="text/css" media="screen" />
<script src="phonegap.js" type="text/javascript" charset="utf-8"></script>
<script src="cordova-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8" src="json2.js"></script>
<script src="childbrowser.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/dsl.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/xui.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function init(){
document.addEventListener("deviceready", onDeviceReady, false);
}
function externalLoad()
{
window.location.href = "http://myapp.com"; //works
}
function locationChanged(newurl) {
console.log("The JS got this url = " + newurl);
}
function closed() {
console.log("The JS got a close event");
}
function showPage(locbar) {
window.plugins.childBrowser.onLocationChange = locationChanged;
window.plugins.childBrowser.onClose = closed;
window.plugins.childBrowser.showWebPage("http://myapp.com", {
showLocationBar: locbar
});
}
function openExternal() {
window.plugins.childBrowser.openExternal("http://myapp.com");
}
</script>
</head>
<body onLoad="externalLoad();">
<button onClick="externalLoad() ;">Load Deals</button> <br>
</body>
</html>
上述方法效果很好,只是它在应用程序 Web 视图中打开了应用程序,并且我无法访问我需要的设备浏览器 cookie。
我尝试过使用 childbrowser 插件,效果很好,但是在页面加载时我无法启动它。如果点击链接,它会完美运行。
我一定遗漏了什么,因为这看起来应该很容易做到。
我们将不胜感激任何正确方向的建议或帮助。
【问题讨论】:
标签: jquery cordova phonegap-plugins