View Full Version : Event listeners in iframe

19 Jan 2011, 6:53 AM
That's the first time I have to ask you for help. By the way, thank's for a great product and docs :)

My issue is probably similar to the one described here: http://www.sencha.com/forum/showthread.php?84386-Ext.menu-didn-t-render-in-Iframe.

I have an app which is working perfectly. But I'd like to embed iframe there, and use Sencha Touch there as well. But I don't want to load sencha-touch.js for the second time, and call Ext.setup(...) with onReady here, because it's slow.

So I figured I'll do something like this (iframe page):

<link rel="stylesheet" href="../../sencha-touch.css" type="text/css">
<script type="text/javascript">
function onLoad () {
new parent.Ext.Button({
text: 'Hello!',
renderTo: document.getElementById('but'),
handler: function ( a, b ) {
<body onload="onLoad()">
<div id="but"></div>

Button is shown inside of the iframe, but when touched, the event is not being fired. So I guess, as in the case from the link above, the problem is with event listening being performed only in parent frame, not within the iframe.

Is there any way to implement this kind of functionality?
Has something changed during last year, since the references post was posted?

Best regards,

21 Jan 2011, 7:03 AM

As for now, I had to change my code to use div instead of iframe, and load HTML contents using div.innerHTML and then, calling all scripts attached to HTML document.
But I find this solution not very elegant. And, also, I'd really like to separate loaded document from parent document.

Best regards!