当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 一个以Javascript+xml的树型列表

Javascript
表格 隔行换色升级版
JavaScript 变量基础知识
fileupload控件 文件类型客户端验证实现代码
extjs DataReader、JsonReader、XmlReader的构造方法
让Firefox支持event对象实现代码
CSS+Js遮罩效果的TAB及焦点图片切换(推荐)
javascript showModalDialog传值与FireFox的window.open 父子窗口传值示例
JQuery 图片延迟加载并等比缩放插件
Jquery作者John Resig自己封装的javascript 常用函数
js 鼠标拖动对象 可让任何div实现拖动效果
页面中js执行顺序
Javascript select下拉框操作常用方法
jQuery 常见学习网站与参考书
javascript currying返回函数的函数
prototype 中文参数乱码解决方案
为javascript添加String.Format方法
asp.net HttpHandler实现图片防盗链
Riot.js 快速的JavaScript单元测试框架
Javascript实现的CSS代码高亮显示
Js 实现表格隔行换色一例

一个以Javascript+xml的树型列表


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

这是在www.java2s.com网站下载的一个以Javascript+xml的树型列表,这个列表界面非常的漂亮,但是由于里面内容比较复杂,而现在项目需要用到这个列表,我到现在还没有摸清怎么在里面让点击一个树型的项目转到别的网页里面去,希望有兴趣的朋友一起研究一下。
部分代码如下: 
 <script> 
  
function dtmlXMLLoaderObject(funcObject,dhtmlObject){ 
 this.xmlDoc=""; 
 this.onloadAction=funcObject||null; 
 this.mainObject=dhtmlObject||null; 
 return this; 
}; 
  
 dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){ 
 this.check=function(){ 
 if(!dhtmlObject.xmlDoc.readyState)dhtmlObject.onloadAction(dhtmlObject.mainObject); 
 else{ 
 if(dhtmlObject.xmlDoc.readyState != 4)return false; 
 else dhtmlObject.onloadAction(dhtmlObject.mainObject);} 
}; 
 return this.check; 
}; 
  
  
 dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName){ 
 if(this.xmlDoc.responseXML){var temp=this.xmlDoc.responseXML.getElementsByTagName(tagName);
var z=temp[0];} 
 else var z=this.xmlDoc.documentElement; 
 if(z)return z; 
 alert("Incorrect XML"); 
 return document.createElement("DIV"); 
}; 
  
  
 dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){ 
 try  

 var parser = new DOMParser(); 
 this.xmlDoc = parser.parseFromString(xmlString,"text/xml"); 

 catch(e){ 
 this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
 this.xmlDoc.loadXML(xmlString); 

 this.onloadAction(this.mainObject); 

 dtmlXMLLoaderObject.prototype.loadXML=function(filePath){ 
 try  

 this.xmlDoc = new XMLHttpRequest(); 
 this.xmlDoc.open("GET",filePath,true); 
 this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this); 
 this.xmlDoc.send(null); 

 catch(e){ 
 if(document.implementation && document.implementation.createDocument) 

 this.xmlDoc = document.implementation.createDocument("","",null); 
 this.xmlDoc.onload = new this.waitLoadFunction(this); 

 else 

 this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
 this.xmlDoc.async="true"; 
 this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this); 

 this.xmlDoc.load(filePath); 

}; 
  
  
function callerFunction(funcObject,dhtmlObject){ 
 this.handler=function(e){ 
 if(!e)e=event; 
 funcObject(e,dhtmlObject); 
 return true; 
}; 
 return this.handler; 
}; 

function getAbsoluteLeft(htmlObject){ 
 var xPos = htmlObject.offsetLeft; 
 var temp = htmlObject.offsetParent; 

 while(temp != null){ 
 xPos+= temp.offsetLeft; 
 temp = temp.offsetParent; 

 return xPos; 

  
function getAbsoluteTop(htmlObject){ 
 var yPos = htmlObject.offsetTop; 
 var temp = htmlObject.offsetParent; 
 while(temp != null){ 
 yPos+= temp.offsetTop