Easily implement a tree-folded navigation bar with XSLT

Source: Internet
Author: User

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.