Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Security Error with iframe

The following issue occurs in Android 4.4 devices and above.

This is what our iframe looks like:

<iframe frameborder=0 id="myIFRAME"></iframe>

The following is the way we are getting iframe programmatically:

if(document.getElementById("myIFRAME")){
        me.setMyIFRAME(document.getElementById("myIFRAME").contentWindow);
}

This is causing a security error related to Protocol mismatch:

"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.

We are using Sencha touch with Cordova to develop our project.

like image 380
Ritika Avatar asked Sep 07 '15 11:09

Ritika


1 Answers

The Cordova security guide says:

If content is served in an iframe from a whitelisted domain, that domain will have access to the native Cordova bridge.

Have you tried adding the external domain to the whitelist inside config.xml?

<access origin="https://google.com" />
like image 194
lifeisfoo Avatar answered Sep 28 '22 17:09

lifeisfoo