PDA

View Full Version : javascript menu defaults to open



krraleigh
08-21-2009, 09:32 PM
I am using an accordian style menu on a site that I am helping with and for some reason it defaults to open most of the time. When first open the site the link for services is always open. Can someone take a look at the code and tell me why it defaults to this open state when someone first lands on the page?

greateropp.com/ (http://greateropp.com/)

Thank you
Kevin

krraleigh
08-25-2009, 12:32 AM
I seem to get quite a few views here.
Is there some piece of information that I am not including?

Kevin

CODE:

<script type="text/javascript" src="javascripts/ddaccordion.js"></script>
<script type="text/javascript" language="javascript1.3">
/***********************************************
* Accordion Content script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
ddaccordion.init({
headerclass: "expandable", //Shared CSS class name of headers group that are expandable
contentclass: "categoryitems", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
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
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
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: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
})


</script>

davelf
08-25-2009, 05:26 AM
so you want to hide the slide on the first open:


defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content



change it into



defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content



remove the 0 value,
If you use the second code, when user open the page no accordion effect will show until they click it.
sorry if i miss some point of your question..
good luck:)

krraleigh
08-25-2009, 10:30 PM
I appreciate the help
works great!

thanx Kevin