Expand and collapse is actually displayed or not displayed (Display:none or block) it differs from visible and invisible (visible or invisible), which is not reserved on the page. This toggle function completes two functions, changing the original hidden properties of TR, so that the original display is not displayed; change the src attribute of the IMG and change the picture.
Toggle.js
function Toggle (ID)
{
var Thisrow = Document.All.Item (ID);
if (Thisrow)
{
if (Thisrow.getattribute ("Expanded") = = ' yes ')
{
Thisrow.setattribute ("Expanded", "no");
Thisrow.children (0). Children (0). Children (0). src = "images/bs.gif";
var allrows = document.all.tags ("TR");
for (Var i=1 i < allrows.length; i++)
{
var row = Allrows[i];
if (Row.getattribute ("ancestorid") = ID)
{
if (Row.getattribute ("Expanded") = = ' Yes ') {
Toggle (Row.getattribute ("id"));
}
Row.classname = ' Navigator-hidden ';
}
}
Thisrow.classname = ' Navigator ';
}
Else
{
Thisrow.setattribute ("Expanded", "yes");
Thisrow.children (0). Children (0). Children (0). src = "images/bo.gif";
var allrows = document.all.tags ("TR");
var depth = parseint (Thisrow.getattribute ("depth"));
for (Var i=1 i < allrows.length; i++)
{
var row = Allrows[i];
if (Row.getattribute ("ancestorid") = = ID &&
parseint (Row.getattribute ("Depth")) = = Depth + 1)
{
Row.classname = ' Navigator ';
}
}
}
}
}
To this end.
It's true that the TOC's functionality is the most basic, for example, I haven't done content and directory synchronization, and some of them can be modified to further slim the XML and XSL files. But for the average user, that's enough.
I sincerely hope that this article can inspire and help you to make a more cool, faster, more convenient and more powerful TOC.