下面是我的代码:
<script src="include/cordova.js" type="text/javascript"></script> <script src="include/sencha-touch-all.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8" src="include/childbrowser.js"></script> <link href="include/sencha-touch.css" rel="stylesheet" type="text/css" />
var childBrowser = null;
if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {
document.addEventListener("deviceready", onDeviceReady, false);
} else {
onDeviceReady();
}
function onDeviceReady(){
console.log("PhoneGap is Ready");
childBrowser = ChildBrowser.install();
}
function openChildBrowser(url)
{
try {
//both of these should work...
var cb = new ChildBrowser();
console.log(cb);
cb.showWebPage('http://www.google.com');
}
catch (err)
{
alert(err);
console.log(err);
}
}..。
还有一些不相关的代码,但当我调用openChildBrowser()时,我收到以下错误:
exec,我相信它是指在cordova对象上调用Uncaught TypeError: Object #<Object> has no method 'exec'的子浏览器。
当我查看cordvoa对象时,我在任何地方都没有看到exec函数...
有什么想法吗?
发布于 2012-05-13 01:37:14
最后,我重新开始使用Eclipse和Phonegap SDK。能够在不使用构建服务的情况下以这种方式工作。
这可能会对某些人有所帮助:
http://phonegap.com/start#android
https://github.com/phonegap/phonegap-plugins/tree/master/Android/ChildBrowser
发布于 2012-05-02 05:12:21
这是针对iOS的还是针对安卓的?这段代码在这两种情况下都可以工作。我发现在使用var cb = new ChildBrowser()时可能会出现错误。我认为清理一下ChildBrowser的调用方式是合适的,但我现在没有时间这样做。这个方法是可行的。Promise :) ps -如果你正在为iOS做这件事,有一个例子可以说明这一点。
ChildBrowser.install();
window.plugins.childBrowser.showWebPage('http://www.google.com');发布于 2012-05-05 11:00:26
据我所知,ChildBrowser还没有完全兼容cordova。
无论如何,在您尝试与ChildBrowser插件通信之前,听起来cordova并没有完成初始化。
尝试连接weinre或其他东西,并测试在cordova完全初始化后可以手动打开子浏览器。确保此代码在脚本加载顺序中位于cordova之后。还要确保你使用的是所有东西的最新版本。
https://stackoverflow.com/questions/10308818
复制相似问题