var closableTab = { //frame加载完成后设置父容器的高度,使iframe页面与父页面无缝对接 frameLoad:function (frame){ var mainheight = $(frame).contents().find('body').height(); alert(mainheight); $(frame).parent().height(mainheight); }, //添加tab addTab:function(tabItem){ //tabItem = {id,name,url,closable} var id = "tab_seed_" + tabItem.id; var container ="tab_container_" + tabItem.id; $("li[id^=tab_seed_]").removeClass("active"); $("div[id^=tab_container_]").removeClass("active"); if(!$('#'+id)[0]){ var li_tab = ' '; }else{ li_tab = li_tab + ''; } var iframeHeight = $(window).height() - 117; var tabpanel = '
'+ ''+ '
'; $('.nav-tabs').append(li_tab); $('.tab-content').append(tabpanel); } $("#"+id).addClass("active"); $("#"+container).addClass("active"); $("#"+container).find($('iframe')).attr('src', tabItem.url); }, //关闭tab closeTab:function(item){ var val = $(item).attr('tabclose'); var containerId = "tab_container_"+val.substring(9); if($('#'+containerId).hasClass('active')){ $('#'+val).prev().addClass('active'); $('#'+containerId).prev().addClass('active'); } $("#"+val).remove(); $("#"+containerId).remove(); } }