我正在尝试在 PhoneGap 中加载我的网络应用程序,但我似乎无法在 iOS 中将其重定向。但是,它确实在浏览器中正确重定向。为了简单起见,我的 JS 看起来像这样:
onDeviceReady: function() {
console.log('Received Device Ready Event');
window.location.href = "http://example.com";
},
我的 config.xml
包含这个:
<plugin name="cordova-plugin-whitelist" spec="1" />
<allow-navigation href="*://example.com/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
知道为什么它可以在浏览器中运行,但不能在 iOS 中运行吗?我确定我遗漏了一些简单的东西......
最佳答案
我想通了。我在 iOS 上使用 PhoneGap Developer 应用程序,结果发现 CSP 被该应用程序覆盖。如果您想测试外部链接,显然需要编译应用程序并将其安装在设备上,而不是使用 PhoneGap Developer 应用程序。看这里:https://github.com/phonegap/connect-phonegap/issues/163
关于javascript - PhoneGap - window.location 在 iOS 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40899994/