【问题标题】:InAppBrowser Not Working with Phonegap BuildInAppBrowser 不适用于 Phonegap 构建
【发布时间】:2015-06-09 23:52:09
【问题描述】:

我正在尝试将 InAppBrowser 插件与 Phonegap Build 一起使用,但是当我单击我的链接时,该网页无法在 InAppBrowser 中打开。我可以从 config.xml 中删除插件,它没有任何区别。我在 config.xml 文件中使用了以下插件。

<gap:plugin name="org.apache.cordova.inappbrowser" version="0.5.2" />

下面是我在我的 js 文件中打开 InAppBrowser 的代码。我正在使用 window.open 调用 InAppBrowser 并使用 google 作为测试。有谁知道我做错了什么?任何帮助是极大的赞赏。

$(document).ready(function() {

    var listHtml = "";

    var url = "http://example.com/mypage.php"
    $.post(url, function(response) {
            var json = $.parseJSON(response);

            $.each(json, function(key, value) {
                listHtml += "<li><a href='#' onclick=window.open('http://www.google.com','_blank','location=yes,toolbar=yes')><img class='ui-circle ui-mini ui-padding' src='" + value.image + "'><h2>" + value.name + "</h2><p><strong>" + value.title + "</strong></p><p><strong>" + value.date + "</strong></p></li>";

                $("#history").html(listHtml);
                $('ul').listview('refresh');

            }); //end list

【问题讨论】:

    标签: javascript jquery cordova build inappbrowser


    【解决方案1】:

    我认为您需要将window.open 绑定到cordova.InAppBrowser.open,请参阅文档here

    $(document).ready(function(){
        window.open = cordova.InAppBrowser.open; // BIND
    
        var listHtml = "";
    
        var url = "http://example.com/mypage.php"
        $.post(url, function(response){
            var json = $.parseJSON(response);
    
            $.each(json, function(key, value){
                listHtml += "<li><a href='#' onclick=window.open('http://www.google.com','_blank','location=yes,toolbar=yes')><img class='ui-circle ui-mini ui-padding' src='"+ value.image +"'><h2>" + value.name +  "</h2><p><strong>"+ value.title + "</strong></p><p><strong>" + value.date +"</strong></p></li>";
    
                $("#history").html(listHtml);
                $('ul').listview('refresh');
    
            });
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多