PDA

View Full Version : Change iFramePanel title from within the iFrame



malstroem
17 Feb 2010, 2:00 AM
Hi there,

I have been searching through this forum for quite some while but did not find a suitable solution yet...
Is it possible to change the title of an iFramePanel from within the iFrame?
That way I could sort of "synchronize" the Panel title with its content...

I use Ext in the iFrame AND outside the iFrame...

Just now i tried something like:

iFramePanel = parent.document.getElementById('iFramePanel ');
iFramePanel.setTitle('NewTitle');

malstroem
20 Feb 2010, 2:16 AM
To make it a little bit clearer:

This is the parent panel - containig the iFramePanel:



Ext.ns('CommonComponents');
CommonComponents.Services=Ext.extend(Ext.Panel,{
constructor:function(){
var c=(typeof arguments[0]=='object')?arguments[0]:{};
c.id = 'servicespanel';
c.title='old title';
c.border=false;
c.layout='fit';
c.style='background:#ffffff';
c.items=[
{
id: 'services_iFramePanel',
xtype:'iframepanel',
border:false,
layout:'fit',
defaultSrc:Configuration.ServicesUrl,
title:''
}
];
CommonComponents.Services.superclass.constructor.apply(this,new Array(c));
},
initComponent:function(){
CommonComponents.Services.superclass.initComponent.apply(this,arguments);
},
Reload:function(){
this.items.items[0].setSrc(Configuration.ServicesUrl+'&t='+(new Date().format('U')));
}
})
Ext.reg('common_services',CommonComponents.Services);


now - within the iFrame I put the following lines to change the parent panels title.
But all I get is a "extServicePanel.setTitle is not a function" in Firebug



servicespanel = parent.document.getElementById('servicespanel');
var extServicePanel = Ext.get(servicespanel);
extServicePanel.setTitle('new title');

fay
20 Feb 2010, 2:57 AM
Try:


var extServicePanel = Ext.getCmp('servicespanel');
extServicePanel.setTitle('new title');

malstroem
20 Feb 2010, 4:02 AM
Thanks fay for your advice - I tried this before...
But the problem is, that the iFrame cannot reference to a parent Ext element...

What I did now and what seems to work is to call a public function in the parent window from within the iFrame window.parent.setiFrameTitle('newTitle');

In this public (parent) function setiFrameTitle(title) I call Ext.getCmp('servicepanel') as you proposed... and there call the Ext.Panel setTitle() method

hendricd
20 Feb 2010, 7:15 AM
Try (from within the nested page):



window.hostMIF.setTitle('Something New');

malstroem
20 Feb 2010, 11:23 AM
@hedricd: thanks for your advice
but I get a "window.hostMIF.setTitle is not a function" in Firebug...

But as mentionend above, I now found a solution with a little detour