



免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
XML+ JS创建树形菜单 简单说明: 思路:从数据岛menuXML中读取数据,从树的根节点开始分析树,利用 hasChildNodes() 方法:是否含有子节点 判断当前节点是否有子节点,如果有子节点继续向下分析 childNodes 对象:子节点对象集合 ,否则返回当前分析结果(树结点对象)。 主要的函数:createTree(thisn /*树结点*/ , sd/*树深度*/) 运行代码 DSTree body,tdfont:12px verdana#treeBoxbackground-color:#fffffa;#treeBox .ecmargin:0 5 0 5;#treeBox .hasItemsfont-weight:bold;height:20px;padding:3 6 0 6;margin:2px;cursor:hand;color:#555555;border:1px solid #fffffa;#treeBox .Itemsheight:20px;padding:3 6 0 6;margin:1px;cursor:hand;color:#555555;border:1px solid #fffffa;/code by star 20003-4-7var HC = color:#990000;border:1px solid #cccccc;var SC = background-color:#efefef;border:1px solid #cccccc;color:#000000;var IO = null;function initTree()var rootn = document.all.menuXML.documentElement;var sd = 0;document.onselectstart = function()return false;document.all.treeBox.appendChild(createTree(rootn,sd);function createTree(thisn,sd)var nodeObj = document.createElement(span);var upobj = document.createElement(span);with(upobj) style.marginLeft = sd*10; className = thisn.hasChildNodes()?hasItems:Items; innerHTML = + thisn.getAttribute(text) +; onmousedown = function() if(event.button != 1) return; if(this.getAttribute(cn) this.setAttribute(open,!this.getAttribute(open); .style.display = this.getAttribute(open)?inline:none; this.all.tags(img)0.src = this.getAttribute(open)?expand.gif:contract.gif; if(IO) IO.runtimeStyle.cssText = ; IO.setAttribute(selected,false); IO = this; this.setAttribute(selected,true); this.runtimeStyle.cssText = SC; onmouseover = function() if(this.getAttribute(selected)return; this.runtimeStyle.cssText = HC; onmouseout = function() if(this.getAttribute(selected)return; this.runtimeStyle.cssText = ; oncontextmenu = contextMenuHandle; onclick = clickHandle;if(thisn.getAttribute(treeId) != null) upobj.setAttribute(treeId,thisn.getAttribute(treeId);if(thisn.getAttribute(href) != null) upobj.setAttribute(href,thisn.getAttribute(href);if(thisn.getAttribute(target) != null) upobj.setAttribute(target,thisn.getAttribute(target);nodeObj.appendChild(upobj);nodeObj.insertAdjacentHTML(beforeEnd,)if(thisn.hasChildNodes() var i; var nodes = thisn.childNodes; var cn = document.createElement(span); upobj.setAttribute(cn,cn); if(thisn.getAttribute(open) != null) upobj.setAttribute(open,(thisn.getAttribute(open)=true); upobj.getAttribute(cn).style.display = upobj.getAttribute(open)?inline:none; if( !upobj.getAttribute(open)upobj.all.tags(img)0.src =contract.gif; for(i=0;inodes.length;cn.appendChild(createTree(nodesi+,sd+1); nodeObj.appendChild(cn);else upobj.all.tags(img)0.src =endnode.gif;return nodeObj;window.onload = initTree;function clickHandle()/ yo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 厂家摆车合同(标准版)
- 2025团队管理自考试题及答案
- 公司重组原有合同(标准版)
- 代理人合同人事合同(标准版)
- 租赁站入股合同(标准版)
- 2025年学历类自考中国古代文学作品选(一)-学前儿童科学教育参考题库含答案解析(5卷)
- 光学竞赛试题及答案
- 全球纺织服装行业2025协作机器人应用趋势研究报告
- 2025年押题宝典教师招聘之《幼儿教师招聘》题库附答案详解【综合题】
- 口腔知识竞赛试题及答案
- 住院患儿实施院内转运临床实践指南2023版课件
- 打包机吊装方案
- 如何列好小说提纲
- 【新教材】部编道德与法治六年级上册-全册-表格式教案教学设计
- 文言实词本义引申义
- 07J902-3 医疗建筑(卫生间、淋浴间、洗池)
- 2024年电工(高级技师)职业鉴定理论考试题库-下(多选、判断题)
- 2024年网上大学智能云服务交付工程师认证考试题库800题(含答案)
- 公共数据交换技术规范
- 2024年福建省高职院校单招《语文》考试复习题库(含答案)
- 中华民族共同体概论课件专家版2第二讲 树立正确的中华民族历史观
评论
0/150
提交评论