extjs 添加选项卡


//添加标签(标签头信息,标签显示地址)
function addtab(tabarea,text,url,pos){
var tab;
try{
if(tabcount==0){
var tabs = new Ext.TabPanel(tabarea, {//向tabarea区域添加标签
tabPosition : pos,//标签头位置 top or bottom
resizeTabs:true, //标签头自动调整大小
monitorResize:true,
minTabWidth: 20,//标签头最小为50
preferredTabWidth:120//标签头最大为150
});
tabcomm=tabs;//把标签对象副给标签全局对象
}
tabh=Ext.get(tabarea).getHeight();//得到区域的高
tabcount++;

var tabFrame = Ext.DomHelper.append(document.body, //创建一个iframe
{tag:'iframe',
id:text, //动态ID
frameBorder:0, //样式
scrolling:'auto', //滚动
src: url, //抵制
name:text,
width:'100%',
height:"100%"
});

tab = tabcomm.addTab(text,text,"",true); //向标签对象中添加新标签(对象名称,头信息,显示内容,可否关闭)
tabgetcount=tabcomm.getCount();
tab.activate();//设置当前窗体选中
tabtext=text;
tab.on('activate',function(){///得到当前标签头信息
tabtext=tabcomm.getActiveTab().getText();

<!--此处是单独处理,针对一次打开多个标签进行验证,并找其对应数组
if(document.getElementById(tabtext).src=="about:blank"){
for(var i=0;i<tabshortcut.length;i++){
if(tabshortcut[i][0]==tabtext){
document.getElementById(tabtext).src=tabshortcut[i][1];
}
}
}

-->
tabActivate(tabtext);
});
tab.setTooltip(text);//设置提示信息
tab.on('beforeclose',function(){//关闭标签事件
tabtext=tabcomm.getActiveTab().getText();//得到当前标签头信息
delArray(tabtext);
Ext.get(tabtext).remove();
tabgetcount--;
});


}catch(exception){}
}


/**
* 在新tabpanel打开页面
*/
function addTab(id,name,url,code){
var tab = Ext.getCmp('mainContent').getItem(id);
if (!tab) {
Ext.getCmp('mainContent').add({
id : id,
title : "<span style='float:left;height:21px;'>name+"</span>",
closable : true,
html : "<iframe id='iframe_" + id + "' scrolling='auto' border='0' frameborder='0' marginwidth='0' marginheight='0' width='100%' height='100%' onload='unPageMask()'></iframe>"
}).show();
//由于IE6是无法解析创建iframe前指定的src属性,所以这里在创建iframe之后再指定路径;如果直接在iframe中指定src,在ie6下会出现空白页面
//document.getElementById("iframe_" + id).src= url;
window.frames["iframe_" + id].location.href =url;
} else {
// 如果tab已存在,则刷新并切换至
window.frames["iframe_" + id].location.reload();
tab.show();
}
pageMask();


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值