【发布时间】:2014-05-07 23:30:15
【问题描述】:
我在我的页面中使用了 Jquery easy tab 插件。
当我右键单击每个选项卡并在新的浏览器选项卡中打开它时,它会显示出来,但是当我按下键盘上的ctrl 键并单击选项卡时,它将在同一个浏览器选项卡而不是新的浏览器选项卡中打开。
我该如何解决这个问题?
我的 jQuery 代码:
$(document).ready(function (e) {
$("html,body").animate({
scrollTop: 0
}, 1000);
var t = window.location.hash.substr(1);
if (t == "oilngas") {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabOil").trigger("click");
window.scrollTo(0, 0);
} else if (t == "utilities") {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabUtl").trigger("click");
} else if (t == "smart") {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabSmt").trigger("click");
window.scrollTo(0, 0);
} else if (t == "heavy") {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabHvy").trigger("click");
window.scrollTo(0, 0);
} else if (t == "") {
$(".offerings_content").show();
}
$("#oil_area").click(function (e) {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabOil").trigger("click");
//prijesh
//var href = $('#tabOil').attr('href');
//var href = window.location.hash.substr(1);
//alert("href : " + href);
//if (href == '#oilngas'){
// window.location.href = href; //causes the browser to refresh and load the requested url
//}
return false;
});
$("#utility_area").click(function (e) {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabUtl").trigger("click");
return false;
});
$("#smartbldng_area").click(function (e) {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabSmt").trigger("click");
return false;
});
$("#heavy_area").click(function (e) {
$(".offerings_content").hide();
$("#tab-container").show();
$("#tabHvy").trigger("click");
return false;
});
});
【问题讨论】:
-
return false;on click handler 负责限制重定向到页面。
标签: javascript jquery tabs