Currenlty我在一个cordova应用程序中嵌入在线网站;我config.xml中如下:允许iframe执行cordova命令
<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标签:
<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://" from accessing a frame with origin "file://". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "file". Protocols must match.
如何允许从外部网站到我的应用程序的这种交互?