【发布时间】:2012-10-18 20:58:48
【问题描述】:
在尝试使用适用于黑莓的 ChildBrowser 插件时,Chrome 开发人员工具中不断出现此错误:TypeError: Cannot call method 'showWebPage' of undefined
在萤火虫中我得到:TypeError: cordova.exec is not a function
"showWebPage", [url, options]);
这是我的代码
index.html
<!DOCTYPE html>
<html>
<head>
<title>Share QR</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery.mobile-1.2.0.min.css" />
<script src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="childbrowser.js"></script>
<script src="jquery.js"></script>
<script src="jquery.mobile-1.2.0.min.js"></script>
<script src="main.js"></script>
<script src="details.js"></script>
</head>
<body id="main" >
<div data-role="page" id="home" data-position="fixed">
<div data-role="header">
<h1>Home</h1>
</div>
<div data-role="content">
<ul data-role="listview" data-filter="true" id="listItem"></ul>
</div>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#home" data-icon="grid">Feeds</a></li>
<li><a href="#videos" data-icon="plus">Videos</a></li>
</ul>
</div><!-- /navbar -->
</div>
</div>
<div data-role="page" id="videos" data-position="fixed" data-add-back-btn="true">
<div data-role="header">
<h1>Home</h1>
</div>
<div data-role="content">
<ul data-role="listview" data-filter="true" id="listItemvid"></ul>
</div>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#home" data-icon="grid">Feeds</a></li>
<li><a href="#videos" data-icon="plus">Videos</a></li>
</ul>
</div><!-- /navbar -->
</div>
</div>
</body>
</html>
main.js
var serviceURL = 'http://localhost/feeds/services/';
function onDeviceReady() {
// Now safe to use the PhoneGap API
alert("Ready");
}
$(document).bind('pageinit', function(){
$('#listItem li').remove();
document.addEventListener("deviceready", onDeviceReady, false);
$.getJSON(serviceURL + 'getdata.php', function(data){
$.each(data, function(index, value){
var output = '';
output += '<li><a href="details.html?id=' + value.id + '"><img src="pics/' + value.id + '.jpg"/>' + value.name + '</a></li>';
$("#listItem").append(output).listview("refresh");
});
});
});
$('#videos').live('pageshow', function(event) {
$('#listItemvid li').remove();
$.getJSON(serviceURL + 'getdata.php', function(data){
$.each(data, function(index, value){
var output = '';
output += '<li><img src="pics/' + value.id + '.jpg"/>' + value.name + '</a></li>';
$("#listItemvid").append(output).listview("refresh");
});
});
});
$('#listItemvid').live('vclick', function(event) {
event.preventDefault();
// alert("i'm running!");
if(window.cordova){
alert("loaded");
var cb = window.plugins.childBrowser;
cb.showWebPage('http://www.google.com',
{ showLocationBar: true });}
else{
alert("Not Available");
}
});
plugin.xml
<plugins>
<plugin name="App" value="org.apache.cordova.app.App"/>
<plugin name="Device" value="org.apache.cordova.device.Device"/>
<plugin name="Camera" value="org.apache.cordova.camera.Camera"/>
<plugin name="NetworkStatus" value="org.apache.cordova.network.Network"/>
<plugin name="Notification" value="org.apache.cordova.notification.Notification"/>
<plugin name="Accelerometer" value="org.apache.cordova.accelerometer.Accelerometer"/>
<plugin name="Geolocation" value="org.apache.cordova.geolocation.Geolocation"/>
<plugin name="File" value="org.apache.cordova.file.FileManager"/>
<plugin name="FileTransfer" value="org.apache.cordova.http.FileTransfer"/>
<plugin name="Contacts" value="org.apache.cordova.pim.Contact"/>
<plugin name="Capture" value="org.apache.cordova.capture.MediaCapture"/>
<plugin name="Battery" value="org.apache.cordova.battery.Battery"/>
<plugin name="Media" value="org.apache.cordova.media.Media"/>
<plugin name="ChildBrowser" value="org.apache.cordova.plugins.childbrowser.ChildBrowser"/>
</plugins>
config.xml
I included
<gap:plugin name="ChildBrowser" src="org.apache.cordova.plugins.childbrowser.ChildBrowser" version="~3" />
我已经搜索谷歌寻求帮助,但似乎每个人都解决了问题,但他们的步骤并没有解决我的问题。
任何帮助将不胜感激
【问题讨论】:
-
你到底想做什么。
-
我正在尝试使用 phonegap 插件:childbrowser,我实际上观察到错误即将到来 frm wen d childBrowser.js 类试图调用 d 本机 java childBrowser.java 类中的副本。
标签: cordova jquery-mobile phonegap-plugins cordova-2.0.0