0

尝试使用黑莓的 ChildBrowser 插件时,我在 Chrome 开发人员工具中不断收到此错误:TypeError: Cannot call method 'showWebPage' of undefined

在萤火虫中,我得到:TypeError:cordova.exec 不是函数

“showWebPage”,[url,选项]);

这是我的代码

索引.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"  />

我已经搜索谷歌寻求帮助,但似乎每个人都解决了这个问题,但他们的步骤并没有解决我的问题。

任何帮助,将不胜感激

4

1 回答 1

0

@Kehinde Kolexinfos Kolade:嘿,您不能将子浏览器用于桌面浏览器。它可以用于移动应用程序。子浏览器允许您在自定义浏览器字段或设备的内置浏览器中显示 Cordova 应用程序中的外部网页。

于 2012-12-20T09:08:45.403 回答