2012-11-03 27 views
1

我有一個應用程序寫在ExtJS的4更新ExtJS的面板用的HTML將呈現IFRAME

一個分頁的幾個標籤只是一個iframe。我創建它就像這樣,它工作正常。

xtype: 'tabpanel', 
title: 'My Embedded Web Pages', 
items : [ 
       { 
        title: 'Google', 
        html : '<iframe width ="100%" height="100%" src="http://www.google.com"><p>Your browser does not support iframes.</p></iframe>' 
       }, 
] 

我想創建頁面動態使用更多的OOP設計模式,但通過擴展Ext.panel.Panel。如果我可以做到這一點,我可以添加更多的功能(如帶有後退按鈕的基本工具欄)。

Ext.define('NS.view.web_browser.WebBrowser' ,{ 

extend: 'Ext.panel.Panel', 

alias: 'widget.web_browser', 

title: 'Web Browser', 

refresh: function() { 
    console.log('refresh'); 
}, 

initComponent: function(arguments) { 
    console.log('initComponent'); 

    this.callParent(arguments); 
}, 
listeners : { 
    viewready : function(view, options) 
    { 
     console.log('viewready'); 
     someText = '<iframe width ="100%" height="100%" src="http://www.google.com/"><p>Your browser does not support iframes.</p></iframe>'; 

     //I'm assuming 'this' is the panel 
     this.update(Ext.util.JSON.encode(someText)); 
    } 
} 
}); 

但是,這是行不通的。我期待它如何將html嵌入到面板中,但我不確定。任何幫助讚賞。

+0

如果您要加載遠程內容,則應使用加載程序:http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-cfg-裝載機 – Hardrada

回答

0

您是否嘗試過用戶名:miframe.js?該文檔可用here。我一直在使用它在ExtJS 3.x中嵌入面板的iframe一段時間。我不知道它是否已經被ExtJS4移植了。