当前位置: 首页 > 图文教程 > 网络编程 > Javascript > TreeView(扩充XMLSelTree)(二)

Javascript
jQuery中isFunction方法的BUG修复
将函数的实际参数转换成数组的方法
javascript 删除数组中重复项(uniq)
js 巧妙去除数组中的重复项
javascript下一种表单元素获取方法存在的问题
javascript 三种数组复制方法的性能对比
js 多层叠的TAB选项卡
javascript 自动标记来自搜索结果页的关键字
起点页面传值js,有空研究学习下
javascript 的Document属性和方法集合
JavaScript 使用简略语法创建对象的代码
使用JQuery进行跨域请求
jquery 经典动画菜单效果代码
jquery 常用操作方法
js提示信息jtip封装代码,可以是图片或文章
javascript面向对象的方式实现的弹出层效果代码
jquery中的sortable排序之后的保存状态的解决方法
js或css实现滚动广告的几种方案
使用JavaScript库还是自己写代码?
js 右键菜单,支持不同对象不同菜单(兼容IE、Firefox)

Javascript 中的 TreeView(扩充XMLSelTree)(二)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 146 ::
收藏到网摘: n/a

TreeView(扩充XMLSelTree

VisualSW

基于XMLJavaScriptTreeView

}

            else

            {

                ReadNode(Element.childNodes[i],s_Text,s_Value,OP);

            }

        }            

    }

    else

    {

        //alert(Element.getAttribute("Title") + Element.getAttribute("CheckData") + Element.getAttribute("Checked"));

        if((Element.getAttribute("Title")==s_Text) && (Element.getAttribute("CheckData")==s_Value))

        {               

            switch(OP)

            {

                case "ADD":

                    var NewNode = oXMLDom.createNode(1, "TreeNode", "");

                    NewNode.setAttribute("Title",ipt_Title.value);

                    NewNode.setAttribute("CheckData","000");

                    NewNode.setAttribute("CHK","true");

                    Element.appendChild(NewNode);

                    break;

                case "MODIFY":

                    Element.setAttribute("Title",ipt_Title.value);

                    Element.setAttribute("Caption",ipt_Caption.value);

                    break;

                case "DELETE":

                    Element.parentNode.removeChild(Element);

                    break;

                default:

                    break;

            }           

        }

    }

}

 

/*

======================================================================

JavaScript鼠标右键菜单

作者:申旺

日期:2004/05/13

注意:

======================================================================

*/

 

var Style;

Style="<style>" +

".skin0" +

"{" +

"      position:absolute;" +

"      text-align:left;" +

"      width:80px;" +

"   border-top-style: #000000 2px solid;" +

"   border-right-style: #000000 2px solid;" +

"   border-left-style: #000000 2px solid;" +

"   border-bottom-style: #000000 2px solid;" +

"      background-color:menu;" +

"      font-family:Verdana;" +

"      line-height:20px;" +

"      cursor:default;" +

"      visibility:hidden;" +

"}" +

".skin1" +

"{" +

"      cursor:default;" +

"      font:menutext;" +

"      position:absolute;" +

"      text-align:left;" +

"      font-family: Arial, Helvetica, sans-serif;" +

"      font-size: 10pt;" +

"      width:120px;" +

"      background-color:menu;" +

"      border:1 solid buttonface;" +

"      visibility:hidden;" +

"      border:2 outset buttonhighlight;" +

"}" +

".menuitems" +

"{" +

"   font-size: 9pt;" +

"   font-family: \"宋体\",Arial;" +

"      padding-left:15px;" +

"      padding-right:10px;" +

"}" +

"-->" +

"</style>";

 

var OutDiv;

OutDiv="<div id=\"ie5menu\" class=\"skin1\" onMouseover=\"highlightie5()\" onMouseout=\"lowlightie5()\">" +

"<div class=\"menuitems\" onclick=\"domenu('close')\">返回</div>" +

"<hr>"+

"<div class=\"menuitems\" onclick=\"domenu('modify')\">修改</div>"+

"<hr>"+

"<div class=\"menuitems\" onclick=\"domenu('add')\">增加</div>"+

"<hr>"+

"<div class=\"menuitems\" onclick=\"domenu('delete')\">删除</div>"+

"</div>";

 

var AddORModify;

AddORModify="<div id=\"addormodify\" class=\"skin0\">" +

"Title:<input id=ipt_Title type=textbox value=\"\">" + "<br>" +

"Caption:<input id=ipt_Caption type=textbox value=\"\">" + "<br>" +

"<input id=btn_Cancel type=button value='取消' onclick=\"JavaScript:HideAddOrModify();\">" +

"<input id=btn_Submit type=button value='确定' onclick=\"JavaScript:Submit();\">" +

"<input type=hidden id=hid_Text value=''><input type=hidden id=hid_Value value=''>" +

"</div>";

 

var Select_Text;

var Select_Value;

 

function Init()

{  

    //write AddOrModify

       document.write(AddORModify);

      

       //write style   

       document.write(Style);

      

       //write menu   

       document.write(OutDiv);

      

       if(document.all&& window.print)

       {

              //ie5menu.className= menuskin;

              document.oncontextmenu= DoNothing;

              document.body.onclick= HideMenuIE5;

       }

}

 

function DoNothing()

{

    return false;

}

 

//初始化右键菜单

Init();

 

function ShowMenuIE5(p_Text,p_Value)

{   

    Select_Text=p_Text;

    Select_Value=p_Value;

   

       var rightedge= document.body.clientWidth-event.clientX;

       var bottomedge= document.body.clientHeight-event.clientY;

       if(rightedge< ie5menu.offsetWidth)

       ie5menu.style.left= document.body.scrollLeft+ event.clientX -

       ie5menu.offsetWidth;

       else

       ie5menu.style.left= document.body.scrollLeft+ event.clientX;

       if(bottomedge< ie5menu.offsetHeight)

       ie5menu.style.top= document.body.scrollTop+ event.clientY -

       ie5menu.offsetHeight;

       else

       ie5menu.style.top= document.body.scrollTop+ event.clientY;

       ie5menu.style.visibility="visible";

      

       addormodify.style.visibility="hidden";

      

       return false;

}

 

function HideMenuIE5()

{

    Select_Text="";

    Select_Value="";

       ie5menu.style.visibility="hidden";

       //addormodify.style.visibility="hidden"; 

}

 

function highlightie5()

{

       if(event.srcElement.className=="menuitems")

       {

              event.srcElement.style.backgroundColor="highlight";

              event.srcElement.style.color="white";         

       }

}

 

function lowlightie5()

{

       if(event.srcElement.className=="menuitems")

       {

              event.srcElement.style.backgroundColor="";

              event.srcElement.style.color="black";

              window.status="";

       }    

}

 

function domenu(src)

{   

    switch(src)

    {

        case "return":

            HideMenuIE5();

            break;

        case "delete":

            if(confirm("确认删除?"))

            {

                DeleteNode(Select_Text,Select_Value);

            }

            break;

        case "add":          

            ShowAddOrModify("add");

            break;

        case "modify":           

            ShowAddOrModify("modify");

        default:

            break;       

    }

}

 

function Submit()

{   

    if(btn_Submit.value=="修改")

    {       

        ModifyNode(hid_Text.value,hid_Value.value);

        HideAddOrModify();

    }

    else

    {

        AddNode(hid_Text.value,hid_Value.value);

        HideAddOrModify();

    }

}

 

function HideAddOrModify()

{

    Select_Text=="";

    Select_Value=="";

    addormodify.style.visibility="hidden";

    ipt_Title.value="";

    ipt_Caption.value="";

}

 

function ShowAddOrModify(src)

{

   

    var rightedge= document.body.clientWidth-event.clientX;

       var bottomedge= document.body.clientHeight-event.clientY;

       if(rightedge< addormodify.offsetWidth)

       addormodify.style.left= document.body.scrollLeft+ event.clientX -

       addormodify.offsetWidth;

       else

       addormodify.style.left= document.body.scrollLeft+ event.clientX;

       if(bottomedge< addormodify.offsetHeight)

       addormodify.style.top= document.body.scrollTop+ event.clientY -

       addormodify.offsetHeight;

       else

       addormodify.style.top= document.body.scrollTop+ event.clientY;

       addormodify.style.visibility="visible";   

      

    if(src=="modify")

    {       

        ipt_Title.value=Select_Text;

        ipt_Caption.value=Select_Text;

        hid_Text.value=Select_Text;

        hid_Value.value=Select_Value;

        btn_Submit.value="修改";

    }

    else

    {

        ipt_Title.value="";

        ipt_Caption.value="";

        hid_Text.value=Select_Text;

        hid_Value.value=Select_Value;

        btn_Submit.value="新增";

    }   

}

代码不是很规范,给大家参考。