简体   繁体   English

链接到Bootstrap导航选项卡中的ID

[英]Linking to an ID inside a Bootstrap nav-tab

We are using Bootstrap nav-tabs on our new website's events pages to create different sections on a single page related to our events — About, Speakers, Travel, Register and so on. 我们正在新网站的活动页面上使用Bootstrap导航选项卡在单个页面上创建与活动相关的不同部分-关于,演讲者,旅行,注册等。

Our events coordinator would like to be able to link directly to the individual speakers who appear on the Speakers tab from outside the website. 我们的活动协调员希望能够直接链接到从网站外部显示在“发言人”选项卡上的各个发言人。 Normally, this is pretty simple — http://domain.name/events/eventspage#speakerID . 通常,这非常简单-http://domain.name/events/eventspage#speakerID

However, because we're using nav-tabs, there isn't an easy and obvious way of creating this link. 但是,由于我们使用的是导航标签,因此没有简单而明显的方法来创建此链接。 I've looked through posts here and elsewhere to see if anyone else has addressed this problem, but have yet to find anything. 我浏览了这里和其他地方的帖子,看看是否有人解决了这个问题,但还没有找到任何东西。

The site was built using Bootstrap 3 and uses ExpressionEngine 2.10 as the CMS. 该网站是使用Bootstrap 3构建的,并使用ExpressionEngine 2.10作为CMS。

You can view a working example of how our events pages are set up at https://www.rjionline.org/events/rjicollab . 您可以在https://www.rjionline.org/events/rjicollab上查看如何设置我们的事件页面的有效示例。

Any suggestions would be appreciated. 任何建议,将不胜感激。

This is how it can work with jQuery: 这就是它与jQuery一起工作的方式:

Select an anchor within a JQUERY Tab from a link on anther webpage 从其他网页上的链接中选择JQUERY标签中的锚点

You can adapt the code from there. 您可以从那里修改代码。

Here you can try this function: 在这里您可以尝试此功能:

function goToTab(){
    var hash=document.location.hash,
        prefix="tab_";
    if(hash)
      $('.nav-tabs a[href='+hash.replace(prefix,"")+']').tab('show')
};

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

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