[英]Activate specific Tab based on URL
Is there any way to activate a specific tab based on the URL if my tabs are setup like this? 如果我的标签是这样设置的,是否有任何方法可以基于URL激活特定标签?
All I need is for a link on www.example1.com/notabs.html to redirect to www.example2.com/tabs.html 我需要的是在www.example1.com/notabs.html上的链接以重定向到www.example2.com/tabs.html
That specific link on www.example1.com/notabs.html should activate www.example1.com/notabs.html上的特定链接应激活
<li><a href="#" data-filter=".Tab2">Tab2</a></li>
Tab2 on www.example2.com/tabs.html www.example2.com/tabs.html上的 Tab2
<li><a href="#" data-filter=".Tab1" class="selected">Tab1</a></li>
<li><a href="#" data-filter=".Tab2">Tab2</a></li>
<li><a href="#" data-filter=".Tab3">Tab3</a></li>
Please view the Javascript for these below 请在下面查看这些的Javascript
//##########################################
// Filter - Isotope
//##########################################
var $container = $('#filter-container');
$container.imagesLoaded( function(){
$container.isotope({
itemSelector : 'figure',
filter: '*',
resizable: false,
animationEngine: 'jquery'
});
});
// filter buttons
$('#filter-buttons a').click(function(){
// select current
var $optionSet = $(this).parents('#filter-buttons');
$optionSet.find('.selected').removeClass('selected');
$(this).addClass('selected');
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
return false;
});
You can use queryString paramaters to redirect passing basic parameters. 您可以使用queryString参数来重定向传递的基本参数。 it would be something like this: 会是这样的:
Html HTML
<li><a href="www.example2.com/tabs.html?tab=tab2" data-filter=".Tab2">Tab2</a></li>
To make things easier, I would suggest adding ids to tab containers 为了使事情变得容易,我建议将ID添加到标签容器
<ul id="tabs">
<li><a href="#" id="tab1" data-filter=".Tab1" class="selected">Tab1</a></li>
<li><a href="#" id="tab2" data-filter=".Tab2">Tab2</a></li>
<li><a href="#" id="tab3" data-filter=".Tab3">Tab3</a></li>
</ul>
Then in this tabs.html javascript: 然后在这个tabs.html javascript中:
$(document).ready(function(){
var queryDict = {};
var search = location.search.replace("==", "=").replace("==", "=").replace("==", "=");
search.substr(1).split("&").forEach(function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]});
if (queryDict[tab]) {
$('#tabs > .selected').removeClass("selected");
$('#'+queryDict[tab]).addClass("selected");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.