问题
I have a tab panel formed of two tabs. I'm trying to access the iframe in each tab by using "window.frames["id"]" but i'm getting undefined when alerting it. How to access the iframe in my case?
tabPanel = Ext.create('Ext.tab.Panel', {
region: 'center',
activeTab: 0,
autoScroll: true,
items: [
{
id:"panel_A",
title: "${tr.A}",
html: "<iframe src= '"+A_url +"' width='100%' height='100%' id='frm_A' name='frm_A' frameborder=0 />",
},{
id:"panel_B",
title: "${tr.B}",
//disabled:tabs_status,
//hidden:hidden,
html: "<iframe src='"+B_url +"' width='100%' height='100%' id='frm_B' name='frm_B' frameborder=0 />",
}]
});
viewport = new Ext.Viewport({
layout:'border',
items:[tabPanel]
});
回答1:
To select DOM elements you can use Ext.dom.Query.select(), alias Ext.query()
.
Ext.dom.Query Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).
More about navigating through DOM with ExtJS in this answer.
Try something like Ext.query('iframe#frm_A');
Working fiddle
来源:https://stackoverflow.com/questions/34831078/accessing-an-iframe-inside-a-tab-panel-extjs4-2