简体   繁体   English

如何访问 iFrame 的 main

[英]How to access main of iFrame

I have created one iFrame window and in that there is separate ext app.我创建了一个 iFrame 窗口,其中有单独的 ext 应用程序。

Win = new Ext.IframeWindow({
                        id: 'MyWinID',
                        modal: true,
                        resizable: true,
                        title: 'H1',
                        closable: true,
                        constrain : true,
                    });
    Win.width = (winWidth / 100) * 90,
    Win.height = (winHeight / 100) * 90,
    Win.show().center();

On the resize I wanted to access the app which is placed in iFrame.在调整大小时,我想访问放置在 iFrame 中的应用程序。

listeners :{
            resize : function(a,b,c){
                // How to access element of main at this point. I am trying this
                var WinFrame =  window.frames['MyWinID']
                }
            }

My main of iFrame app is我的 iFrame 应用程序的主要内容是

Ext.define('My.view.main.Main', {
    extend: 'Ext.panel.Panel',
    xtype: 'app-main',

    requires: [
        'Ext.plugin.Viewport',
        'Ext.tab.Panel',
    ],

    controller: 'main',
    viewModel: 'main',
    layout: 'border',

    items: [{
        xtype: 'toolbar',
        frame: true,
        region: 'south',
        items: [ some item]
    },
    {
        title: 'App',
        itemId: 'selectionPanel',
        region: 'west',
        xtype: 'panel',
        scroll: 'y',
        frame: true,
         items: []
    },
    {
        xtype: 'panel',    
        region: 'center',
        frame: true,
        scrollable: true,
        scroll: 'y',    
        itemId: 'abc',
        reference: 'abc',
        layout: {
            //type: 'anchor',
            type: 'vbox',
            align: 'stretch'
        },
        items: []
    }]
});

Can you please suggest how to achieve this.您能否建议如何实现这一目标。

Javascript basic rule: JavaScript 基本规则:

"global" variables (eg Ext ) are available in the tree under window and vice versa, so window.Ext.getCmp("MyWinID") and Ext.getCmp("MyWinID") are the same. “全局”变量(例如Ext )在window下的树中可用,反之亦然,因此window.Ext.getCmp("MyWinID")Ext.getCmp("MyWinID")是相同的。

Javascript rule for frames:框架的 Javascript 规则:

window.frames[id] contains the selected frame's window element. window.frames[id]包含所选框架的window元素。

Both together yield the answer your question, which can be summarized in this simple example:两者共同产生了您的问题的答案,可以在这个简单的示例中进行总结:

window.frames['MyAppFrame'].Ext.getCmp("MyTestContainer").add({
    xtype:'button',
    handler:function(btn) {
        btn.up('form').submit();
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM