PDA

View Full Version : Switch Content Script II -> Specify open/close for every instance



Keiser
02-23-2006, 06:21 PM
Hey all,

I'd like the ability to specify whether each individual instance is open or closed.

I've seen code that states all open, or all closed on load.

Perhaps pass an aditional parameter of initial state?

Is there something out there already?

No existing page for viewing, just a concept idea.

Ideas?

jscheuer1
02-26-2006, 06:11 AM
This can be done (using the original DD version (http://www.dynamicdrive.com/dynamicindex17/switchcontent2.htm) of the script) by simply marking each content element that you want originally hidden individually with inline style. From the demo:


<div id="sc2" class="switchcontent" style="display:none;">
Java is completely different from JavaScript- the former is a compiled language while the later is a scripting language.
</div>

A nice touch would be that so (as is the original design of the script) these (now originally hidden) content elements can still be seen by non-javascript enabled browsers, use the noscript and script tags this way:


<noscript><div id="sc2" class="switchcontent"></noscript>
<script type="text/javascript">
document.write('<div id="sc2" class="switchcontent" style="display:none;">')
</script>
Java is completely different from JavaScript- the former is a compiled language while the later is a scripting language.
</div>