以下问题出现在Android 4.4及以上的设备上。
这是我们的 iframe 的样子:
<iframe frameborder=0 id="myIFRAME"></iframe>
以下是我们以编程方式获取 iframe 的方式:
if(document.getElementById("myIFRAME")){
me.setMyIFRAME(document.getElementById("myIFRAME").contentWindow);
}
这会导致与协议(protocol)不匹配相关的安全错误:
"Uncaught SecurityError: Blocked a frame with origin "https://www.google.com" from accessing a frame with origin "file://". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "file". Protocols must match.
我们使用 Sencha touch 和 Cordova 来开发我们的项目。
最佳答案
If content is served in an iframe from a whitelisted domain, that domain will have access to the native Cordova bridge.
您是否尝试过添加外部域 to the whitelist里面 config.xml
?
<access origin="https://google.com" />
关于javascript - iframe 的安全错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32437226/