Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 从子html关闭外部窗口_Extjs - Fatal编程技术网

Extjs 从子html关闭外部窗口

Extjs 从子html关闭外部窗口,extjs,Extjs,我是ExtJS新手 这是我的窗口定义: this.dialog = new Ext.Window({ title : "About us", layout : 'anchor', modal : true, autoEl : { tag : "iframe", id: "myframe", src : "../editor/actorseditor.html", height: 500, width : 600

我是ExtJS新手

这是我的窗口定义:

this.dialog = new Ext.Window({
title : "About us",
layout  : 'anchor',
modal   : true,
autoEl : {
        tag : "iframe",
        id: "myframe",
        src : "../editor/actorseditor.html",
        height: 500,
        width : 600
} });   
this.dialog.show();
我想从“ActorEdit.html”关闭对话框窗口

如何做到这一点。此外,打开的窗口没有关闭按钮


提前感谢

我假设在ActorEdit.html中,您必须有一个按钮

在此按钮中,您可以设置此侦听器:

listeners : {
    click : function () {
         Ext.getCmp('yourdialogid').close();
    }
}
var parentDialogWindow = window.parent.Ext.cmp('ID_OF_DIALOG_WINDOW');
parentDialogWindow[parentDialogWindow.closeAction]();

您还需要在对话框中添加一个id。

我假设在ActorEdit.html中,您必须有一个按钮

在此按钮中,您可以设置此侦听器:

listeners : {
    click : function () {
         Ext.getCmp('yourdialogid').close();
    }
}
var parentDialogWindow = window.parent.Ext.cmp('ID_OF_DIALOG_WINDOW');
parentDialogWindow[parentDialogWindow.closeAction]();

您还需要在对话框中添加id。

仅当iFrame中的html页面与父页面来自同一应用程序时,此操作才有效。或者至少协议、子域、域和端口都是相同的

您需要在父页面中公开一个全局函数,该函数将由子页面(iframe)中运行的JavaScript调用

在子页面中,您可以调用:

 if (window.parent && window.parent.myGlobalFunction) {
       window.parent.myGlobalFunction('hello!');
  }
在父页面中,您包括以下全局函数(当然可以根据您的意愿命名):

这假设您正在使用MVC,并且您创建了属性“app”,并在应用程序启动函数中将其设置为“This”。您有一个控制器正在监听应用程序范围内的事件,如下所示:

Ext.define('MyApp.controller.Qnum', {
    extend:'Ext.app.Controller',
    init:function(){
        this.control({
            ...
        });
        //listen for app wide event fired by : MyApp.app.fireEvent('closeMyWindow',input);
        this.application.on({
            closeMyWindow: this.closeWindowItsDrafty,
            scope: this
        });
    },
    closeWindowItsDrafty:function(){
       //get reference to my window
       //call myWindow.close();
    }

只有当iFrame中的html页面与父页面来自同一应用程序时,这才有效。或者至少协议、子域、域和端口都是相同的

您需要在父页面中公开一个全局函数,该函数将由子页面(iframe)中运行的JavaScript调用

在子页面中,您可以调用:

 if (window.parent && window.parent.myGlobalFunction) {
       window.parent.myGlobalFunction('hello!');
  }
在父页面中,您包括以下全局函数(当然可以根据您的意愿命名):

这假设您正在使用MVC,并且您创建了属性“app”,并在应用程序启动函数中将其设置为“This”。您有一个控制器正在监听应用程序范围内的事件,如下所示:

Ext.define('MyApp.controller.Qnum', {
    extend:'Ext.app.Controller',
    init:function(){
        this.control({
            ...
        });
        //listen for app wide event fired by : MyApp.app.fireEvent('closeMyWindow',input);
        this.application.on({
            closeMyWindow: this.closeWindowItsDrafty,
            scope: this
        });
    },
    closeWindowItsDrafty:function(){
       //get reference to my window
       //call myWindow.close();
    }

请尝试在关闭按钮侦听器中执行以下操作:

listeners : {
    click : function () {
         Ext.getCmp('yourdialogid').close();
    }
}
var parentDialogWindow = window.parent.Ext.cmp('ID_OF_DIALOG_WINDOW');
parentDialogWindow[parentDialogWindow.closeAction]();

请尝试在关闭按钮侦听器中执行以下操作:

listeners : {
    click : function () {
         Ext.getCmp('yourdialogid').close();
    }
}
var parentDialogWindow = window.parent.Ext.cmp('ID_OF_DIALOG_WINDOW');
parentDialogWindow[parentDialogWindow.closeAction]();

在配置中将窗口设置为
closeable:true
。@cclerville Done。。无影响我不知道您是否注意到我的错误,但它是
closable:true
而不是
closeable
。在配置中将窗口设置为
closeable:true
。@cclerville Done。。没有影响我不知道你是否注意到我的错误,但是它的
closable:true
和not
closeable
@Chunk Birkin我的ActorEditor.html是一个简单的html页面,带有一个加载图表的脚本和两个按钮,即添加和取消。在何处添加listener@Hermant库马尔。你还打算如何从内页关闭窗口?你需要一个按钮或链接,你需要一个项目来关闭它,你把Listener放在那里,这将不起作用,因为在IFrame中运行的JS仅限于范围内的对象。@Chunk Birkin My ActorEdit.html是一个简单的html页面,有一个用于加载图表的脚本和两个按钮,即添加和取消。在何处添加listener@Hermant库马尔。你还打算如何从内页关闭窗口?你需要一个按钮或链接,你需要一个项目来关闭它,你把监听器放在那里。这将不起作用,因为在IFrame中运行的JS仅限于其中的对象。我在ExtJs窗口中添加了close按钮,然后添加了一个监听器,从中我触发了关闭窗口的事件。它工作正常。我在ExtJs窗口中添加了close按钮,然后添加了一个侦听器,从中我触发了关闭窗口的事件。工作正常。