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.
如何允許從外部網站到我的應用程序的這種交互?