【问题标题】:Ionic window.open is not working in ios deviceIonic window.open 在 ios 设备中不起作用
【发布时间】:2020-08-28 22:35:55
【问题描述】:

我只有 window.open(),用户将在文本字段中搜索任何内容并单击建议链接,因此结果将在设备浏览器中打开。我的代码在系统浏览器(chrome)和 android 设备中运行良好,但在 ios 设备中无法正常工作。看看我下面的代码。

angular.forEach($scope.data, function(value, key) {
          var pageListElement = "";
          if(value.Name != undefined) {
             angular.forEach(value.Topics, function(value, key) {
              pageListElement = '<ion-item class="item-avatar-left energized item item-complex ionItemDisp" '+
                'id="page-list-item1" href="#" onclick="window.open(\'' + value.FirstURL + '\''+
                ', \'_system\', \'location=yes\'); return false;"><a class="item-content" ng-href="#" href="#">'+
                '<img src="' + value.Icon.URL + '"><h2energized>' + value.Text + '</h2energized>'+
              '</a></ion-item>';
               });
            } else if(value.FirstURL != undefined) {
                pageListElement = '<ion-item class="item-avatar-left energized item item-complex ionItemDisp" '+
                  'id="page-list-item1" href="#" onclick="window.open(\'' + value.FirstURL + '\''+
                  ', \'_system\', \'location=yes\'); return false;"><a class="item-content" ng-href="#" href="#">'+
                  '<img src="' + value.Icon.URL + '"><h2energized>' + value.Text + '</h2energized>'+
                '</a></ion-item>';
            } else {
              alert("unhandled query");
            }
          searchPageList.append(pageListElement);
        
        });
      }).
      error(function(data, status,headers, config) {
        alert("Status is " + status);
      });
    }
})

请帮帮我。

【问题讨论】:

标签: javascript angularjs ionic-framework


【解决方案1】:
window.open('url', '_system');  
//Loads in the system browser 
window.open('url', '_blank');   
//Loads in the InAppBrowser
window.open('url', '_blank', 'location=no');
//Loads in the InAppBrowser with no location bar
window.open('url', '_self');
//Loads in the Cordova web view 

更多信息:https://wiki.apache.org/cordova/InAppBrowser

【讨论】:

    【解决方案2】:

    如果你像我一样是个笨蛋,我无法让 InAppBrowser 插件免费工作,但修复非常简单。

    当您在组件顶部声明 cordova 时,您将其声明为类型 any 并且没有智能感知功能,因此如果您拼写错误,您将不会收到警报。

    我正在使用:

    cordova.InaAppBrowser.open
    

    我应该一直在使用

    cordova.InAppBrowser.open
    

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 2017-07-12
      • 1970-01-01
      • 2015-08-12
      • 2015-05-17
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多