在尝试使用Blackberry的ChildBrowser插件时,Chrome Developer Tools一直出现此错误:TypeError:无法调用未定义的方法'showWebPage'
在firebug中我得到:TypeError:cordova.exec不是函数
“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" />
我搜索谷歌寻求帮助,但每个人似乎都解决了这个问题,但他们的步骤并没有解决我的问题。
任何帮助将不胜感激
答案 0 :(得分:0)
@Kehinde Kolexinfos Kolade:嘿,你不能将儿童浏览器用于桌面浏览器。它可用于移动应用程序。子浏览器允许您在自定义浏览器字段或设备的内置浏览器中显示Cordova应用程序中的外部网页。