iFrame parent is null on Android 4.0+
-------------------------------------
Key: CB-258
URL: https://issues.apache.org/jira/browse/CB-258
Project: Apache Callback
Issue Type: Bug
Components: Android
Affects Versions: 1.3.0
Environment: Android 4.0+ (Ice Cream Sandwach)
PhoneGap 1.4.1
Reporter: Jared Warren
Assignee: Joe Bowser
When I load an html file inside an iframe that file cannot access it's parent.
Also "deviceready" is never called. See the following code:
index.html
{code}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sand Box testing</title>
<script src="phonegap-1.4.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function doParentSomething() {
alert("Oh, HI!");
}
function onDeviceReady() {
console.log("Device is ready");
}
function onBodyLoad() {
if (typeof navigator.device == 'undefined') {
document.addEventListener("deviceready", onDeviceReady,
false);
} else {
onDeviceReady();
}
}
</script>
</head>
<body onload="onBodyLoad()">
<iframe width="200px" height="200px" id="framer"
src="frameContents.html"></iframe>
</body>
</html>
{code}
frameContents.html
{code}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sand Box testing</title>
<script type="text/javascript" charset="utf-8">
function doSomething() {
console.log("doSomething:" + parent.parent.location.href);
try {
parent.doParentSomething();
} catch (e) {
console.log("parentFail:" + e);
}
}
function onBodyLoad() {
console.log("iframe loaded.");
}
</script>
</head>
<body onload="onBodyLoad()">
<button onclick="doSomething()">Say HI</button>
</body>
</html>
{code}
Logs:
{quote}
02-16 12:08:22.325: I/Web Console(9093): iframe loaded. at
file:///android_asset/www/frameContents.html:17
[Click "Say HI" button]
02-16 12:08:28.286: I/Web Console(9093):
doSomething:file:///android_asset/www/frameContents.html at
file:///android_asset/www/frameContents.html:8
02-16 12:08:28.286: I/Web Console(9093): parentFail:TypeError: Object [object
DOMWindow] has no method 'doParentSomething' at
file:///android_asset/www/frameContents.html:12
{quote}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira