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 6370949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:59:48+00:00 2026-05-25T00:59:48+00:00

I have links that are inside a jquery accordion on a page. When a

  • 0

I have links that are inside a jquery accordion on a page. When a visitor clicks on one of those links then hits the back button to return to my page, I’d like the accordion that contained the link to be open.

My assumption was that I should use the navigation:true setting and add hashtags to the different accordions, but that isn’t working for me.

Here is what I have:

// lots of content above here // 

<div id="accordion">

<h5><a href="#area1">Area 1 header</a></h5>
<div>
    <ul>
        <li><a href='http://www.externalsite.com'>Link to an external site</li>
    </ul>
</div>

<h5><a href="#area2">Area 2 header</a></h5>
<div>
    <ul>
        <li><a href='http://www.anotherexternalsite.com'>Link to another external site</li>
    </ul>
</div>

// At the bottom of the page below the jquery and jquery ui references //

<script type="text/javascript">
    $(document).ready(function(){
       $("#accordion").accordion({active:false,collapsible:true,autoHeight:false,navigation:true});
    });
</script>

The accordion works just fine while I’m in the page. If I click one of the external links and then click the back button, all the accordions are collapsed. I think it will be a irritating experience for people to have to open the accordion they were previously on to click the next link – or read more about that area, which is why I’m trying to make this change.

Am I headed down the right road using the navigation option?

  • 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-05-25T00:59:49+00:00Added an answer on May 25, 2026 at 12:59 am

    Here’s a solution I created using the BBQ plugin from Ben Alman http://benalman.com/projects/jquery-bbq-plugin/

    <script>$(function(){
    $('#accordion').accordion({ collapsible: true, autoHeight: false, navigation: true });
    
    var accordion = $('.ui-accordion');    
    acc_a_selector = '.ui-accordion-header a ';  
    accordion.accordion({ event: 'change'});    
    accordion.find( acc_a_selector ).click(function(){
        var state = {},
        id = $(this).closest( '.ui-accordion' ).attr( 'id' ),
        idx = $(this).parent().parent().length;
        ndx = $(this).parent().index() * 0.5;
        state[ id ] = ndx;
        hashlink = $(this).attr('href');
        $.bbq.pushState( state );
    });
    
    $(window).bind( 'hashchange', function(e) { 
        accordion.each(function(){
            var idx = $.bbq.getState( this.id, true ) || 0;
            accordion.children('h3').eq(idx).filter(':not(.ui-state-active)').parent().accordion( "option", "active", idx);
        });
    })
    
    $(window).trigger( 'hashchange' );});</script>
    

    and the HTML should be relatively the same:

    <div id="accordion">
    <h3><a href="#">Area 1 header</a></h3>
    <div>
        <ul>
            <li><a href='http://www.externalsite.com'>Link to an external site</a></li>
        </ul>
    </div>
    <h3><a href="#">Area 2 header</a></h3>
    <div>
        <ul>
            <li><a href='http://www.anotherexternalsite.com'>Link to another external site</a></li>
        </ul>
    </div></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with some links inside a div and some outside that
I have a modal popup with several links inside that have the :confirm and
I have links like these that I want to change: mypage.com?page=missions&id=5 mypage.com?page=hello I tried
I have an update panel on my page with some links that have onClick
On this page there is a list of footer links that have a little
I have links on a ,page that I want to use to jump to
I'm trying to assign a class that I have within the jQuery UI accordion
I have a website that uses ajax jquery and colorbox. Inside the div #content
I have this page that displays pictures in a div. I have jquery cycle
I have a simple accordion menu using jQuery. When I click a link inside

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.