Twitter Bootstrap选项卡:转到页面重新加载或超链接上的特定选项卡 [英] Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink
本文介绍了Twitter Bootstrap选项卡:转到页面重新加载或超链接上的特定选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个网页,我正在使用Twitter的Bootstrap框架及其 Bootstrap标签JS 。除了一些小问题外,它的效果很好,其中之一是我不知道如何直接从外部链接直接访问特定的选项卡。例如:
< a href =facility.php#home>主页< / a>
< a href =facility.php#notes>备注< / a>
应分别在Home标签和Notes标签中点击链接外部网页 解决方案
但它可以帮助其他人:
// Javascript启用链接到标签
var url = document.location。的toString();
if(url.match('#')){
$('。nav-tabs a [href =#'+ url.split('#')[1] +'] ')的.tab(' 节目');
$ b $ //改变页面重载的散列值
$('。nav-tabs a')。on('shown.bs.tab',function(e) {
window.location.hash = e.target.hash;
})
I'm developing a web page in which I'm using Twitter's Bootstrap Framework and their Bootstrap Tabs JS. It works great except for a few minor issues, one of which is I do not know how go directly to a specific tab from an external link. For example:
<a href="facility.php#home">Home</a>
<a href="facility.php#notes">Notes</a>
should go to the Home tab and the Notes tab respectively when clicked on the links from an external page
解决方案
Here is my solution to the problem, a bit late perhaps. But it could maybe help others:
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
}
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})
这篇关于Twitter Bootstrap选项卡:转到页面重新加载或超链接上的特定选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文