user1328021
user1328021

Reputation: 9840

Linking to a particular tab in a URL

I'd like to link to a particular tab on a page through a URL. Is this possible without using Jquery (which I have basically no knowledge in)?

Here is my HTML. I want the link to open the YouTube tab.

<div class="tabbable span12">
    <ul class="nav nav-tabs">
        <li><h3> Videos including YouTube links </h3></li>
        <li class="pull-right">
            <a href="#YouTube" data-toggle="tab">YouTube</a>
        </li>
    <li class="active pull-right">
            <a href="#Newest" data-toggle="tab">Newest</a>
        </li>

Just say my link is: "/stuff/videos". How can I link to the YouTube tab on this page in the easiest way.

I tried "/stuff/videos#YouTube" but this did not work.

BTW I'm using the Django framework if that changes anything.

Update: Here's the code that instantiates the tab. I'm using Bootstrap.

        <div class="tab-pane" id="YouTube">

Upvotes: 0

Views: 347

Answers (1)

Marat Tanalin
Marat Tanalin

Reputation: 14123

Use onclick JS handler for tab link to switch to a tab dynamically, and check location.hash on page load to switch to corresponding tab automatically.

Upvotes: 2

Related Questions