萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> Javascript樹型菜單的方法

Javascript樹型菜單的方法

 看到園友發表了一篇關於JS樹的文章,看了之後,覺得應該可以精簡不少代碼,

想到了以前做的項目裡面用到了一個JS樹,於是試著修改了一下,現把代碼貼出來與大家共享,還請大家多扔磚頭!

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 <html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title></title>

    <script src="JS/Tree.js" type="text/javascript"></script>

</head>

<body>

    <form id="form1" runat="server">

    <div>

<%--    <asp:TreeView ID="TreeView1" runat="server" ShowLines="True">

    </asp:TreeView>--%>

    <div id="treeOrgan"></div>

    </div>

    </form>

    <script type="text/javascript" language="javascript">

        var tree;

        window.onload = function()

        {

            if (tree != "") {

                tree = new treeview("treeview", "../images/Tree", false, false);

                var parNode = new node("人員列表", "人員列表", "", "0", "F", false, "");

                //caption, title, url, target, tag,check,callback

                tree.add(parNode);

                tree.create(document.getElementById("treeOrgan"));

 

                InitNode(0, parNode);

                parNode.expand();

            }

        }

        function InitNode(id, parNode) {

            if (parNode.nodes.length > 0) {

                parNode.toggle();

copyright © 萬盛學電腦網 all rights reserved