Skip to content

Commit 6995983

Browse files
committed
新增iframeForceRefresh强制刷新iframe功能
1 parent 85f2ed8 commit 6995983

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/nbproject/

jquery.addtabs.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
/**
22
* http://git.oschina.net/hbbcs/bootStrap-addTabs
33
* Created by joe on 2015-12-19.
4-
* @param {type} options {
5-
* content string||html 直接指定内容
6-
* close bool 是否可以关闭
7-
* monitor 监视的区域
8-
* }
9-
*
10-
* @returns
114
*/
125
$.fn.addtabs = function (options) {
136
var obj = $(this);
@@ -19,6 +12,7 @@ $.fn.addtabs = function (options) {
1912
tab: '.tab-addtabs',
2013
iframeUse: true, //使用iframe还是ajax
2114
iframeHeight: $(window).height() - 50, //固定TAB中IFRAME高度,根据需要自己修改
15+
iframeForceRefresh: false, //点击后强制刷新对应的iframe
2216
callback: function () {
2317
//关闭后回调函数
2418
}
@@ -35,7 +29,7 @@ $.fn.addtabs = function (options) {
3529
});
3630
}
3731
$(options.monitor).on('click', '[addtabs]', function (e) {
38-
if ($(this).attr('url').indexOf("javascript") !== 0) {
32+
if ($(this).attr('url').indexOf("javascript:") !== 0) {
3933
if ($(this).is("a")) {
4034
e.preventDefault();
4135
}
@@ -54,7 +48,7 @@ $.fn.addtabs = function (options) {
5448
window.history.pushState(state, title, pushurl);
5549
}
5650
$(this).data("pushstate", null);
57-
_add({
51+
_add.call(this, {
5852
id: id,
5953
title: $(this).attr('title') ? $(this).attr('title') : $(this).html(),
6054
content: content,
@@ -118,17 +112,24 @@ $.fn.addtabs = function (options) {
118112
navobj.append(title);
119113
}
120114
tabobj.append(content);
115+
} else {
116+
//强制刷新iframe
117+
if (options.iframeForceRefresh) {
118+
$("#" + conid + " iframe").attr('src', function (i, val) {
119+
return val;
120+
});
121+
}
121122
}
122-
123+
localStorage.setItem("addtabs", $(this).prop('outerHTML'));
123124
//激活TAB
124125
$("#" + tabid).addClass('active');
125126
$("#" + conid).addClass("active");
126127
_drop();
127128
};
128129

129130
_close = function (id) {
130-
var tabid = 'tab_'+id;
131-
var conid = 'con_'+id;
131+
var tabid = 'tab_' + id;
132+
var conid = 'con_' + id;
132133
//如果关闭的是当前激活的TAB,激活他的前一个TAB
133134
if (obj.find("li.active").attr('id') == tabid) {
134135
if ($("#" + tabid).prev().not(".tabdrop").size() > 0) {

0 commit comments

Comments
 (0)