繁体   English   中英

从外部链接打开活动标签

[英]Open an active tab from external link

我正在使用引导程序3在一个项目上工作。我想从“主页”页面链接到特定的打开选项卡。 我阅读并测试了很多机会,但没有任何效果。

我的最新消息:

 $activetabbuehne = (params.activeTab is null or params.activeTab == 'tab_a') ? 'class="active"' : ''; $activetabhoehe = (params.activeTab == 'tab_b') ? 'class="active"' : ''; $activetabaudio = (params.activeTab == 'tab_c') ? 'class="active"' : ''; $activetabstudio = (params.activeTab == 'tab_d') ? 'class="active"' : ''; $activetabsonder = (params.activeTab == 'tab_e') ? 'class="active"' : ''; $activetabinstall = (params.activeTab == 'tab_f') ? 'class="active"' : ''; 
 <ul class="nav nav-pills nav-stacked col-xs-12 col-md-4"> <li $activetabbuehne><a href="#tab_a" data-toggle="pill" style="font-weight:500;">BÜHNENBAU<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li> <li $activetabhoehe><a href="#tab_b" data-toggle="pill" style="font-weight:500;">HÖHENARBEITEN<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 26px;color: #db001b;">+</span></a></li> <li $activetabaudio><a href="#tab_c" data-toggle="pill" style="font-weight:500;">AUDIO-, VIDEO-, LICHTTECHNIK<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li> <li $activetabstudio><a href="#tab_d" data-toggle="pill" style="font-weight:500;">STUDIO<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li> <li $activetabsonder><a href="#tab_e" data-toggle="pill" style="font-weight:500;">SONDERLÖSUNGEN<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li> <li $activetabinstall><a href="#tab_f" data-toggle="pill" style="font-weight:500;">INSTALLATIONEN<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li> </ul> 

这是我用于dev.page上的测试的链接:

https://amphire.de/dev/leistungen/?activeTab=tab_a

感谢您的帮助。

一种可能的JavaScript解决方案是,在参数指定的链接上触发click事件。 它将像这样工作:

这将是一个示例代码:

<ul class="nav nav-pills nav-stacked col-xs-12 col-md-4">
  <li><a href="#tab_a" data-toggle="pill" style="font-weight:500;">BÜHNENBAU<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li>
  <li><a href="#tab_b" data-toggle="pill" style="font-weight:500;">HÖHENARBEITEN<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 26px;color: #db001b;">+</span></a></li>
  <li><a href="#tab_c" data-toggle="pill" style="font-weight:500;">AUDIO-, VIDEO-, LICHTTECHNIK<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li>
  <li><a href="#tab_d" data-toggle="pill" style="font-weight:500;">STUDIO<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li>
  <li><a href="#tab_e" data-toggle="pill" style="font-weight:500;">SONDERLÖSUNGEN<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li>
  <li><a href="#tab_f" data-toggle="pill" style="font-weight:500;">INSTALLATIONEN<span style="font-weight:500; float:right;font-weight: 700;float: right;font-size: 23px;color: #db001b;">+</span></a></li>
</ul>

<script type="text/javascript">

// function from https://stackoverflow.com/a/979997/3695983
function gup( name, url ) {
  if (!url) url = location.href
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( url );
  return results == null ? null : results[1];
}

// get the value of the activeTab parameter
var targetTab = gup("activeTab", window.location.href);

// trigger the click so that tab activates and shows content
$("a[href='#" + targetTab + "']").click();

</script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM