Ionic window.open无法在iOS上运行

时间:2022-03-28 18:44:08

I know this is a duplicate question but none of the solutions seem to work for me. This works perfectly fine on Android and in browser but on iOS nothing happens.

我知道这是一个重复的问题,但没有一个解决方案似乎适合我。这在Android和浏览器中完全正常,但在iOS上没有任何反应。

html:

<img ng-src="{{coupon.mainImage}}" ng-click="openWindow(coupon.site)">

Ionic window.open无法在iOS上运行

openWindow function:

$scope.openWindow = function(site) { window.open(site, '_system'); }

$ scope.openWindow = function(site){window.open(site,'_ system`); }

I've also tried using the InAppBrowser plugin but it still doesn't work.

我也尝试过使用InAppBrowser插件,但它仍然无效。

1 个解决方案

#1


1  

You should use the InAppBrowser cordova plugin like someone stated. You could then create a util method like this:

你应该像有人说的那样使用InAppBrowser cordova插件。然后,您可以创建一个这样的util方法:

  sendToUrl(url: string): void {
        if (window.cordova) {
            cordova.InAppBrowser.open(url, '_system');
        } else {
            window.open(url, '_blank');
        }
    }

#1


1  

You should use the InAppBrowser cordova plugin like someone stated. You could then create a util method like this:

你应该像有人说的那样使用InAppBrowser cordova插件。然后,您可以创建一个这样的util方法:

  sendToUrl(url: string): void {
        if (window.cordova) {
            cordova.InAppBrowser.open(url, '_system');
        } else {
            window.open(url, '_blank');
        }
    }