日期:2014-05-17  浏览次数:21136 次

JSP页面引用JS文件无效
引用的一个树的程序,不知道为虾米无效捏?请各位大师帮看下.^_^
JSP页面:
HTML code

<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><script type="text/javascript" src="../js/tree.js"></script> 
                <script type="text/javascript">
                var TREE_ITEMS = [
                ['频道管理','channelManage.jsp'],
                ];
              </script>
              <script type="text/javascript" src="../js/tree_tpl.js"></script>
            <script type="text/javascript">
                new tree (TREE_ITEMS, tree_tpl);
            </script>
          </td>
        </tr>
     </table>


调用的两个JS文件:
tree.js
JScript code

function tree (a_items, a_template) {

    this.a_tpl      = a_template;
    this.a_config   = a_items;
    this.o_root     = this;
    this.a_index    = [];
    this.o_selected = null;
    this.n_depth    = -1;
    
    var o_icone = new Image(),
        o_iconl = new Image();
    o_icone.src = a_template['icon_e'];
    o_iconl.src = a_template['icon_l'];
    a_template['im_e'] = o_icone;
    a_template['im_l'] = o_iconl;
    for (var i = 0; i < 64; i++)
        if (a_template['icon_' + i]) {
            var o_icon = new Image();
            a_template['im_' + i] = o_icon;
            o_icon.src = a_template['icon_' + i];
        }
    
    this.toggle = function (n_id) {    var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) };
    this.select = function (n_id) { return this.a_index[n_id].select(); };
    this.mout   = function (n_id) { this.a_index[n_id].upstatus(true) };
    this.mover  = function (n_id) { this.a_index[n_id].upstatus() };

    this.a_children = [];
    for (var i = 0; i < a_items.length; i++)
        new tree_item(this, i);

    this.n_id = trees.length;
    trees[this.n_id] = this;
    
    for (var i = 0; i < this.a_children.length; i++) {
        document.write(this.a_children[i].init());
        this.a_children[i].open();
    }
}
function tree_item (o_parent, n_order) {

    this.n_depth  = o_parent.n_depth + 1;
    this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];
    if (!this.a_config) return;

    this.o_root    = o_parent.o_root;
    this.o_parent  = o_parent;
    this.n_order   = n_order;
    this.b_opened  = !this.n_depth;

    this.n_id = this.o_root.a_index.length;
    this.o_root.a_index[this.n_id] = this;
    o_parent.a_children[n_order] = this;

    this.a_children = [];
    for (var i = 0; i < this.a_config.length - 2; i++)
        new tree_item(this, i);

    this.get_icon = item_get_icon;
    this.open     = item_open;
    this.select   = item_select;
    this.init     = item_init;
    this.upstatus = item_upstatus;
    this.is_last  = function () { return this.n_order == this.o_parent.a_children.length - 1 };
}

function item_open (b_close) {
    var o_idiv = get_element('i_div' + this.n_id);
    if (!o_idiv) return;
    
    if (!o_idiv.innerHTML) {
        var a_children = [];
        for (var i = 0; i < this.a_children.length; i++)
            a_children[i]= this.a_children[i].init();
        o_idiv.innerHTML = a_children.join('');
    }
    o_idiv.style.display = (b_close ? 'none' : 'block');
    
    this.b_opened = !b_close;
    var o_jicon = document.images['j_img' + this.n_id],
        o_iicon = document.images['i_img' + this.n_id];
    if (o_jicon) o_jicon.src = this.get_icon(true);
    if (o_iicon) o_iicon.src = this.get_icon();
    this.upstatus();
}

function item_select (b_deselect) {