Extjs中如何关闭parent对象窗口打开的window对象

来源:互联网 发布:校园网络广播系统方案 编辑:程序博客网 时间:2024/04/28 14:55

有a,b两个页面,a页面为主页面,有按钮一个,点击按钮弹出一个windows对象,在其中显示b页面。b页面中也有一个按钮,点击关闭窗口。

a.htm (部分代码)
 

<script type="text/javascript">
function openWindow(id,title,url,width,height){
    var win = Ext.get(id)
    if (win) {
        win.close();
        return;
    }
    win = new Ext.Window({
        id:id,
        title:title,
        layout:'fit',
        width:width,
        height:height,
        closeAction:'close',
        collapsible:true,
        plain: false,
        resizable: true,
        html : '<iframe frameborder="0" width="100%" height="100%" src="'+url+'"></iframe>'
    });
    win.show();
}

function myfunction(){
    openWindow('b-win','窗口中打开b页面','b.htm',400,300);
}
</script>
<input type="button" name="button1" value="打开窗口" onClick="myfunction()">

b.htm(部分代码)

<script type="text/javascript">
function closewin(){
    var win = parent.Ext.getCmp('b-win');
    if (win) {win.close();}
}
</script>
<input type="button" name="button1" value="关闭a打开的窗口" onClick="closewin()">