Dynadot

JavaScript Expand/Collapse

Spaceship Spaceship
Watch
Impact
2
Hi all!

If your in need of a simple script to have an expandable/collapsable menu, use my script:
HTML:
<script langauge="JavaScript" type="text/javascript">
function doMenu(item) {
 obj=document.getElementById(item);
 col=document.getElementById("x" + item);
 if (obj.style.display=="none") {
  obj.style.display="block";
  col.innerHTML="[-]";
 }
 else {
  obj.style.display="none";
  col.innerHTML="[+]";
 }
}
</script>
Then just layout a simple div:
HTML:
<a href="JavaScript:doMenu('main');" id=xmain>[+]</a> Main Item
<div id=main style="margin-left:1em">
 <a href=#>Item 1</a><br>
 <a href=#>Item 2</a><br>
 <a href=#>Item 3</a>
</div>
<br>

This should work in Internet Explorer 4.x+ and Firefox but you'll have to do a few checks to make it Netscape compatiable (which im not gonna explain).
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
i was looking for this for my download zone website, i will use it as microsoft download senter used.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back