easyui tab页

function addTab(title, href,icon){    
       var tt = $('#tt');    
       var maxLength = 10;
       var tabCount = tt.tabs('tabs').length+1;
       var hasTab = tt.tabs('exists', title);//如果tab已经存在
       if (hasTab){//则选中并刷新该tab            
           tt.tabs('select', title);    
           refreshTab({tabTitle:title,url:href});    
       } else if(tabCount <= maxLength){    
           var content="";  
           if (href){    
               content = '';    
           } else {    
               content = '未实现';    
           }    
           tt.tabs('add',{    
                title:title,    
                closable:true,   
                select:true, 
                border:false,
                content:content  
           });    
        }  else{//不能超过十个
            alert('友情提示:您当前打开了太多的页面,如果继续打开,会造成程序运行缓慢,无法流畅操作!')
        }      
    }    
function refreshTab(cfg){    
        var refresh_tab = cfg.tabTitle?$('#mytabs').tabs('getTab',cfg.tabTitle):$('#mytabs').tabs('getSelected');    
        if(refresh_tab && refresh_tab.find('iframe').length > 0){    
        var _refresh_ifram = refresh_tab.find('iframe')[0];    
        var refresh_url = cfg.url?cfg.url:_refresh_ifram.src;    
        //_refresh_ifram.src = refresh_url;    
        _refresh_ifram.contentWindow.location.href=refresh_url;    
        }    
    } 

     window.οnlοad=function()  
        {  
            var pages=[{pageName:"task",title:"任务下发",icon:"icon-task"},{pageName:"track",title:"任务跟踪",icon:"icon-track"},{pageName:"report",title:"数据分析",icon:"icon-report"}];  
            for (var i = 0; i < pages.length; i++) {  
                var href= PROJECT_URL + "/drilling/"+pages[i].pageName;  
                addTab(pages[i].title,href,pages[i].icon);  
            }  
        };  

限制长度 :打开太多会造成程序运行缓慢

你可能感兴趣的:(前端)