View Full Version : ContentPanel with IFRAME

Lloyd K
18 Oct 2007, 5:40 AM
I have a ContentPanel which hosts an <iframe/> and in the activate event I want to get the iframe from the panel so I can perform operations on it, only I'm not sure how?! Can anyone point me in the right direction?

18 Oct 2007, 5:47 AM

Lloyd K
18 Oct 2007, 5:52 AM
Yes thanks, but doesn't that just return the ContentPanel <div> element, how do I then go through the `children` I assume to find the frame?

18 Oct 2007, 6:49 AM
If your iframe is one of several children, why not just give it an id in your markup and use Ext.get('iframeid').dom.src = url;

if its created dynamically (without an id and name) you'll have to find it (starting at the panel):

var iframe= Ext.select('iframe',false,panel.getDom()).first().dom.src=url ;

Or, if your iframe is flying solo and you need to snoop, study this extension. (http://extjs.com/forum/showthread.php?t=12706) It should point you in the right direction. Its getHostDocument Method will get you the iframe's document object. Then you can traverse nodes from there.

Then, you can try Ext.select('.className',true,panel.getHostDocument());

This will return a Ext.CompositeElement collection of the iframes elements, but you'll have to manipulate them manually as there is no Ext library loaded within the Iframe window (unless the url you loaded in there includes the Ext framework).

18 Oct 2007, 7:25 AM
See earlier response revised.

Lloyd K
18 Oct 2007, 8:35 AM
Hi yes I solved this now thanks for the help. This issue is actually in relation to my other post about Grid's and hidden iframes, trying to refresh them when I change tabs.