利用javascirpt我们可以很容易的在HTML中实现树,而不需要使用ASP,JSP,PHP等等编写动态程序,当然如果要和数据库结合,下面的代码也很容易移植。
首先,我们看一下实现这个树形结构的javascript代码。
common.js
<!--
function showCurrentSection()
{
var objCurrentSection = document.getElementById("navcurrentsection");
if (objCurrentSection != null)
{
objCurrentSection.style.display = "block";
objCurrentSection.parentElement.childNodes[0].className = "open";
if (objCurrentSection.parentElement.parentElement.nodeName == "UL")
showSection(objCurrentSection.parentElement.parentElement);
}
}
function showSection(objSection)
{
objSection.style.display = "block";
objSection.parentElement.childNodes[0].className = "open";
if (objSection.parentElement.parentElement != null && objSection.parentElement.parentElement.nodeName == "UL")
showSection(objSection.parentElement.parentElement);
}
-->
function showCurrentSection()
{
var objCurrentSection = document.getElementById("navcurrentsection");
if (objCurrentSection != null)
{
objCurrentSection.style.display = "block";
objCurrentSection.parentElement.childNodes[0].className = "open";
if (objCurrentSection.parentElement.parentElement.nodeName == "UL")
showSection(objCurrentSection.parentElement.parentElement);
}
}
function showSection(objSection)
{
objSection.style.display = "block";
objSection.parentElement.childNodes[0].className = "open";
if (objSection.parentElement.parentElement != null && objSection.parentElement.parentElement.nodeName == "UL")
showSection(objSection.parentElement.parentElement);
}
-->
|
上一篇:收集整理了一些javascript 经典函数 下一篇:用DHTML中的Popup Object跨框架显示菜单 |


