Even more twisty HTML
Whew! Yesterday I received a number of comments and complaints about my small twisty (disclosure triangle) library. To review:
- It didn’t work in Internet Explorer. (Not too surprising since I don’t have access to a Windows machine for testing.)
- It was a little ugly. (Okay, no one said that, but I think it was implied.)
- The hidden sections would display for a moment before being hidden.
- It wasn’t keyboard accessible.
- I had a typo in the script.
- The hiding animation wasn’t the same speed as the twisty animation.
So I’ve tried again with some good ideas from the SWAT tooklit. You can try the script.aculo.us animated version or the plain non-animated version. You can also simply download the whole thing as a tar file to play with.
To use this on your own, you need to include the twisty.js file in your code:
<script type="text/javascript" src="twisty.js"></script>
You should also include the two external style sheets:
<link rel="stylesheet" href="twisty.css" type="text/css" media="screen"></link>
<link rel="stylesheet" href="twisty-print.css" type="text/css" media="print"></link>
You no longer need any changes to your <body> tag.
To define a twisty, use this template:
<div class="collapsible"><a href="javascript:toggleTwisty('uniqueid');">The Section Title<img class="twisty" src="twisty-down.gif"></a>
<div id="uniqueid">
<div>
Section Content
</div>
</div>
</div>
If you want the section to default to hidden, simpy add this code to the end of the above code snippet. (after the last </div>)
<script type="text/javascript">
hideTwisty('uniqueid');
</script>
Hopefully, this version works better.


