extjs tabpanel 添加、刷新iframe

网上查到iframe 的刷新用 location.reload(),不过在我的extjs环境中location未定义

添加tab方法:

var addtab = function (id, title, iconCls, url, closable) {
        if (!Ext.getCmp(id)) {
            var close = true;
            if (closable != null) {
                close = closable;
            }
            var content = '';
            var page = tabpage.add({
                id: id,
                title: title,
                iconCls: iconCls,
                closable: close,
                autoScroll: true,
                html: content,
                // loader: {
                //     url: url,
                //     loadMask: true,
                //     autoLoad: true,
                //     scripts: true,
                //     listeners: {
                //         exception: function (lo, response, options, e) {
                //             page.setHtml(response.responseText);
                //         }
                //     }
                // }
            });
        }
        tabpage.setActiveTab(id);
    }

刷新方法:

function refreshTab(tab) {
    var html = tab.config.html;
    var iframe = frames['iframe_' + tab.config.id];
    var src = iframe.src;
    iframe.src = '';
    iframe.src = src;
}

将src重置一下即可刷新,tab是tabpage.getActiveTab()得到的当前活动页面

你可能感兴趣的:(extjs)