View Full Version : Accordion Modifications

02-07-2008, 04:50 PM
1) Script Title: Accordion Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm

3) Describe problem:

What I need to do is make the browser forget your menu selection when you navigate away from the page, not just when you close the browser. It's a bit odd to navigate away from a page and come back to it half an hour with the last menu you selected displaying.

02-07-2008, 06:00 PM
If I understand you right, this should do it:

<script type="text/javascript">

headerclass: "expandable", //Shared CSS class name of headers group that are expandable
contentclass: "categoryitems", //Shared CSS class name of contents group
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "normal" //speed of animation: "fast", "normal", or "slow"


Simply set the highlighted part in the above code to false and that should take care of it.

Hope this helps.

02-07-2008, 06:21 PM
I tried this initially, but that makes it so after each click of a category item, the menus reset.

From what I understand, their are cookies assigned so that the browser remembers which menu was last opened and keeps it open in a given session.

I want it to remember this only when the site is active in the browser. Meaning, I want the last selected menu to be persistent, but I need it to "reset" once the user navigates away from the page. not just for a browser session. So when they come back, the last menu selected doesn't display. As it is now, this only happens when the browser is closed.

02-07-2008, 09:31 PM
I'm not sure I understand. What you said:

Meaning, I want the last selected menu to be persistent, but I need it to "reset" once the user navigates away from the page.

Why would the state of the headers reset if you have yet to navigate away from the current page, regardless of whether persistence is on or off?

02-07-2008, 09:43 PM
Sorry, I'm really bad at making myself clear unless I'm on the phone or face-to-face with someone.

What I mean is that with the persistence on, it works the way I want it to until I decide to navigate away from the page.

If I am the end-user, and I browse to a site that is utilizing this script, and I choose "Category 1" and reveal its category items, "Category 1" stays "open". Now I have browsed away from the site. Two hours later, I go back to the site and "Category 1" is still "open".

I want it to be closed in this kind of situation, but I want persistence to be on as long as I am viewing the site. Currently, it does what I want only if I exit my browser and re-open it. Is there a way to program this so that it "forgets" that I opened a category list if I navigate away from the site?

02-07-2008, 11:26 PM
I see. So to rephrase, you're asking if the current persistence feature can be limited so it expires as soon as the user leaves the site itself, rather than close the browser window altogether. Off the top of my head, I don't see any easy way to do this unfortunately. The concept behind it is similar to how "Site exist popup ads" that was once popular operated, in that a pop up ads only pops up when the user leaves the site in question, not just a particular page within the site. I've not really researched into how that's accomplished though.