1.ParentPage.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="Ext/resources/css/ext-all.css" mce_href="Ext/resources/css/ext-all.css"> <mce:script type="text/javascript" src="Ext/adapter/ext/ext-base.js" mce_src="Ext/adapter/ext/ext-base.js"></mce:script> <mce:script src="Ext/ext-all.js" mce_src="Ext/ext-all.js" type="text/javascript"></mce:script> <mce:script type="text/javascript"><!-- Ext.onReady(function() { var win = new Ext.Window({ title: "Ext子窗体访问父窗体", width: 800, height: 500, constrain: true, layout: "border", items: [ { region: "west", width: 500, margins: "3 3 3 3", cmargins: "3 3 3 3", items: { xtype: "tabpanel", height: 500, border: false, activeTab: 0, items: [ { title: "TAB1", border: false , html: "TAB1" } ] } }, { region: "center", margins: "3 3 3 0", cmargins: "3 3 3 0", html: '<iframe id="iframe" src="SubPage.htm" mce_src="SubPage.htm" frameborder="0" scrolling="auto" style=<mce:script type="text/javascript" src="http://hi.images.csdn.net/js/blog/tiny_mce/themes/advanced/langs/zh.js" mce_src="http://hi.images.csdn.net/js/blog/tiny_mce/themes/advanced/langs/zh.js"></mce:script><mce:script type="text/javascript" src="http://hi.images.csdn.net/js/blog/tiny_mce/plugins/syntaxhl/langs/zh.js" mce_src="http://hi.images.csdn.net/js/blog/tiny_mce/plugins/syntaxhl/langs/zh.js"></mce:script>"border:0px none;height:100%; width:100%;"></iframe>' } ] }); window.AddTab = function() { var panel = win.get(0).get(0); var p = new Ext.Panel({ title: "TAB2", closable: true, border: false, html: "通过子页面来添加一个tab页" }) panel.add(p); panel.doLayout(); panel.setActiveTab(p); } win.show(); }); // --></mce:script> <title id="page-title"></title> </head> <body> </body> </html> 2.SubPage.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>zoujp_xyz测试</title> </head> <body> <button οnclick="fn();"> 给父窗体添加一个tab页</button> <br /> <br /> <br /> <br /> <br /> <br /> <div>我是一个iframe页面</div> </body> </html> <mce:script type="text/javascript"><!-- var fn = function() { parent.AddTab(); } // --></mce:script>