Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:31:01+00:00 2026-06-07T08:31:01+00:00

So on the site STVPlus we use bootstrap and the tabs script to show

  • 0

So on the site STVPlus we use bootstrap and the tabs script to show episodes and articles lists for various tv shows. I am having an issue where once the page has loaded (usually) it works fine, you can select a tab and the appropriate div will show. However if you select an already active div the page jumps down.Also when loading the page with a hash tag like so episodes hash tag link, then it automatically jumps down when page is fully loaded. I have tried stepping through the JS code using chrome dev tools, however I could not find anything obvious.

Any help would be appreciated.

Sample code:

$(function()
{
    $('.sidebar').jScrollPane();

  // Bind an event to window.onhashchange that, when the hash changes, gets the
  // hash and adds the class "selected" to any matching nav link.
  $(window).hashchange( function(){
    var hash = location.hash;


    if ( hash == '#episodes'){
        //e.preventDefault();
        $('.nav-pills a:last').tab('show');
    }else{
        //e.preventDefault();
        $('.nav-pills a:first').tab('show');
    }

  })

  // Since the event is only triggered when the hash changes, we need to trigger
  // the event now, to handle the hash the page may have loaded with.
  $(window).hashchange();
  return false;
});

the episodes div container is like so

<div class="tab-pane" id="episodes">    ..... </div>

and the tab you click is like so

<ul class="nav nav-pills pull-right" data-tabs="tabs">
   <li class="active"><a href="<?php echo current_url(); ?>#articles">Latest Articles</a></li>
   <li><a href="<?php echo current_url(); ?>#episodes">Upcoming Episodes</a></li>
   </ul>

I use the latest jquery, with http://benalman.com/projects/jquery-hashchange-plugin/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:31:03+00:00Added an answer on June 7, 2026 at 8:31 am

    This is what would be my approach concerning your problem :

    I’m not sure that you need the hashchange plugin – except for some document.location.hash fallback (if there’s any).

    The following code uses the classic bootstrap tabs, manually activated, and a bit of onready code that will show the tab matching the hash.

    var hasHash = false;
    var hash = document.location.hash;
    if(hash) {
        hasHash = true;
        var $toggleTab = $('a[href='+hash+']');
        if($toggleTab.length) $toggleTab.tab('show');
    }
    

    Tab activation :

    $('.nav > li > a').click(function(event) {
        event.stopPropagation();
        var $this = $(this);
        $this.tab('show');
        if(hasHash) document.location.hash = $this.attr('href');
    });
    

    Based on the HTML :

    <ul class="nav nav-pills" data-tabs="tabs">
        <li class="active"><a href="#articles" data-target="#articles-tab">Latest Articles</a></li>
        <li><a href="#episodes" data-target="#episodes-tab">Upcoming Episodes</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane" id="episodes-tab">episodes</div>
        <div class="tab-pane active" id="articles-tab">articles</div>
    </div>
    

    Demo (jsfiddle) and Hash demo (jsfiddle)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My site contains a Developers Window which shows various breakdowns on the query's ran
the site is resizable, so I can not use px, and sometimes it's a
My site : jQuery Animation (`comsat.js`: `showPlayerActionView()`): if (container == cs_characterSliderPlayerOne){ container.show(slide, {direction: left},
My site generates its rss feed in http://mysite.com/sydnication/rss/articles path. I want to redirect all
Test site: http://wfwgm.stage.philosophydesign.com/ I have included: <script src=http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js></script> to give :before support in IE6
Our site has multiple wizards where various data is collected over several pages, and
Our site currently uses Richfaces 3.3.3 and JSF 2. There are various native custom
Site loads fine in IE8,9,FF & Chrome. I can't seem to remedy the issue
Site here . Why is it that the code works for $('#club').change(function(event) but not
site.com/link?p=2 give $_GET['p']==2 even though i've already made site.com/link rewrite to site.com/index.php?page=link So, i'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.