I am trying to add a link on a different page to open in a tab pane on another page (specifically on tab8)

Please find my code below:

<div class="tabbable">
  <ul class="nav nav-pills nav-stacked">
    <li class="active"><a href="#tab1" data-toggle="tab">Investment Planner</a></li>
    <li><a href="#tab2" data-toggle="tab">Take the Portfolio Challenge</a></li>
    <li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Portfolio Manager</a>
      <ul class="dropdown-menu">
        <li><a href="#tab3" data-toggle="tab">Create a new e-Portfolio</a></li>
        <li><a href="#tab4" data-toggle="tab">Link e-Portfolio</a></li>
        <li><a href="#tab5" data-toggle="tab">Manage my e-Portfolios</a></li>
        <li><a href="#tab6" data-toggle="tab">Buy/Sell Shares</a></li> 
      </ul>
    </li>
    <li><a href="#tab7" data-toggle="tab">Find a Stockbroker</a></li>
    <li><a href="#tab8" data-toggle="tab">Browse Investment Strategies</a></li>
  </ul>
  <div class="tab-content">
    <div class="tab-pane active" id="tab1">
      <p>Placeholder 1</p>
    </div>
    <div class="tab-pane" id="tab2">
      <p>Placeholder 2</p>
    </div>
    <div class="tab-pane" id="tab3">
      <p>Placeholder 3</p>
    </div>
    <div class="tab-pane" id="tab4">
      <p>Placeholder 0</p>
    </div>
    <div class="tab-pane" id="tab5">
      <p>Placeholder text</p>
    </div>
    <div class="tab-pane" id="tab6">
      <p>Placeholder help</p>
    </div>
    <div class="tab-pane" id="tab7">
      <p>Placeholder help</p>
    </div>
    <div class="tab-pane" id="tab8">
      <p>Placeholder help</p>
    </div>
  </div>
</div>​

Open in new window

Jonah OgbuwaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
http://localhost:49684/WebForm1.aspx#tab8

append #tab8 to the link to the original page
0
Jonah OgbuwaAuthor Commented:
Thanks David,
I have done that (appending #tab8 to the link to the original page) but it it keeps opening the page with the default (1st) tab open. It doesn't open tab8.
0
David Johnson, CD, MVPOwnerCommented:
you code doesn't collapse so it is hard to see what is or is not selected.
0
leakim971PluritechnicianCommented:
add this in the head section after all your scripts :
    <script>
        jQuery(function($) {
            var h = window.location.hash;
            if(h && /#tab\d/.test(h)) {
                $(".tabbable .nav.nav-pills.nav-stacked li").removeClass("active");
                $(".tabbable .nav.nav-pills.nav-stacked li a[href='" + h +"']").click();
            }
        });
    </script>

Open in new window


full page :
<!DOCTYPE html>
<html>
<head>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script>
        jQuery(function($) {
            var h = window.location.hash;
            if(h && /#tab\d/.test(h)) {
                $(".tabbable .nav.nav-pills.nav-stacked li").removeClass("active");
                $(".tabbable .nav.nav-pills.nav-stacked li a[href='" + h +"']").click();
            }
        });
    </script>
</head>
<body>
<div class="tabbable">
    <ul class="nav nav-pills nav-stacked">
        <li><a href="#tab1" data-toggle="tab">Investment Planner</a></li>
        <li><a href="#tab2" data-toggle="tab">Take the Portfolio Challenge</a></li>
        <li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Portfolio Manager</a>
            <ul class="dropdown-menu">
                <li><a href="#tab3" data-toggle="tab">Create a new e-Portfolio</a></li>
                <li><a href="#tab4" data-toggle="tab">Link e-Portfolio</a></li>
                <li><a href="#tab5" data-toggle="tab">Manage my e-Portfolios</a></li>
                <li><a href="#tab6" data-toggle="tab">Buy/Sell Shares</a></li>
            </ul>
        </li>
        <li><a href="#tab7" data-toggle="tab">Find a Stockbroker</a></li>
        <li><a href="#tab8" data-toggle="tab">Browse Investment Strategies</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab1">
            <p>Placeholder 1</p>
        </div>
        <div class="tab-pane" id="tab2">
            <p>Placeholder 2</p>
        </div>
        <div class="tab-pane" id="tab3">
            <p>Placeholder 3</p>
        </div>
        <div class="tab-pane" id="tab4">
            <p>Placeholder 0</p>
        </div>
        <div class="tab-pane" id="tab5">
            <p>Placeholder text</p>
        </div>
        <div class="tab-pane" id="tab6">
            <p>Placeholder help</p>
        </div>
        <div class="tab-pane" id="tab7">
            <p>Placeholder help</p>
        </div>
        <div class="tab-pane" id="tab8">
            <p>Placeholder help</p>
        </div>
    </div>
</div>​
</body>
</html>

Open in new window


if you want to handle 3,4,5,6, you should insert/simulate a new click after testing which tab is selected, of course...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jonah OgbuwaAuthor Commented:
Thank you, @leakim971! This worked for me!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.