我正在使用 PHonegap 构建服务为 droid 创建一个简单的包装器,它将显示 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 View 中打开应用程序,并且我无权访问我需要的设备浏览器 cookie。
我尝试使用 childbrowser 插件,效果很好,但在加载页面时我无法启动它。如果点击该链接,则效果完美。
我一定错过了一些东西,因为这看起来应该很容易做到。
任何正确方向的建议或帮助将不胜感激。
最佳答案
“ native ”cookie 与“真实”cookie 的实现方式可能有所不同。解决方法是打开一个特殊页面,并在参数中包含 cookie 值。这会在真实浏览器中设置 cookie 并重定向到主页(或任何需要的地方)。这需要一些工作,但保证在所有条件下都能工作。
关于jquery - PhoneGap 应用程序加载页面加载时的内部浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12875794/