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 = '<iframe scrolling="auto" frameborder="0" id="iframe_' + id + '"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
            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()得到的当前活动页面

猜你喜欢

转载自blog.csdn.net/wyljz/article/details/79409610
今日推荐