You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "David Marques (Commented) (JIRA)" <ji...@apache.org> on 2012/03/10 17:08:56 UTC

[jira] [Commented] (CB-258) iFrame parent is null on Android 4.0+

    [ https://issues.apache.org/jira/browse/CB-258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13226884#comment-13226884 ] 

David Marques commented on CB-258:
----------------------------------

Hello Jared,

There is an issue in the webkit engine that prevents this to work on local files (http://code.google.com/p/chromium/issues/detail?id=47416)

I would suggest trying to avoid that kind of intra frame interaction for web apps running on top of phonegap for now.

Hope it helps,

David
                
> 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
>              Labels: android, iframe
>
> 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