【问题标题】:Cordova - window.open doesn't work on IOSCordova - window.open 在 IOS 上不起作用
【发布时间】:2023-03-15 02:41:01
【问题描述】:

当我使用 IOS 时,我无法在我的 Cordova 应用中打开链接

window.open('http://maps.apple.com/?q='+label, '_system');

但它适用于(但不在浏览器中):

window.location.href = 'http://maps.apple.com/?q='+label;

在我的 config.xml 中,我将其列入白名单:

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />

在我的 index.html 中:

<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:">

我真的不明白这个问题..

谢谢

【问题讨论】:

    标签: ios cordova hybrid-mobile-app phonegap


    【解决方案1】:

    在我的 iOS Cordova 应用程序中,window.open() 仅在事件与触摸相关而不是与 onDeviceReady() 或 setTimeout() 等自动事件相关时才起作用。

    在 onclick() 事件后执行 window.open 可以正常工作。

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-12
      相关资源
      最近更新 更多