【发布时间】:2016-10-20 13:42:14
【问题描述】:
当前,我正在一个 Cordova 应用程序中嵌入在线站点;我的 config.xml 如下:
<plugin name="cordova-plugin-whitelist" spec="1" />
<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:*" />
<allow-navigation href="*" />
我的 index.html 有以下元标记:
<meta http-equiv="Content-Security-Policy" content="default-src *;
style-src * 'self' 'unsafe-inline' 'unsafe-eval';
script-src * 'self' 'unsafe-inline' 'unsafe-eval';">
现在我需要从内部站点执行(应用程序的)codova 命令,我正在使用以下代码:
window.parent.cordova.plugins.barcodeScanner.scan(function (result) {},
function (error) {});
但它(正确地)失败了:
Uncaught SecurityError: Blocked a frame with origin "http://" 访问带有源的框架 “文件://”。请求访问的帧有一个“http”协议, 正在访问的帧具有“文件”协议。协议必须匹配。
如何允许从外部网站到我的应用进行这种交互?
【问题讨论】: