1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* 增加标签页
*/
function addTab(options) {
//option:
//tabMainName:tab标签页所在的容器
//tabName:当前tab的名称
//tabTitle:当前tab的标题
//tabUrl:当前tab所指向的URL地址
var exists = checkTabIsExists(options.tabMainName, options.tabName);
if(exists){
$("#tab_a_"+options.tabName).click();
} else {
$("#"+options.tabMainName).append('
'+options.tabTitle+'');
//固定TAB中IFRAME高度
mainHeight = $(document.body).height() - 5;
var content = '';
if(options.content){
content = option.content;
} else {
content = '
';
}
$("#"+options.tabContentMainName).append('
'+content+'
');
$("#tab_a_"+options.tabName).click();
}
}
/**
* 关闭标签页
* @param button
*/
function closeTab (button) {
//通过该button找到对应li标签的id
var li_id = $(button).parent().parent().attr('id');
var id = li_id.replace("tab_li_","");
//如果关闭的是当前激活的TAB,激活他的前一个TAB
if ($("li.active").attr('id') == li_id) {
$("li.active").prev().find("a").click();
}
//关闭TAB
$("#" + li_id).remove();
$("#tab_content_" + id).remove();
};
/**
* 判断是否存在指定的标签页
* @param tabMainName
* @param tabName
* @returns {Boolean}
*/
function checkTabIsExists(tabMainName, tabName){
var tab = $("#"+tabMainName+" > #tab_li_"+tabName);
//console.log(tab.length)
return tab.length > 0;
}