一个以Javascript xml的树型列表
2008-02-23 08:05:33来源:互联网 阅读 ()
部分代码如下: <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;
temp = temp.offsetParent;
}
return yPos;
}
function convertStringToBoolean(inputString){if(typeof(inputString)=="string")inputString=inputString.toLowerCase();
switch(inputString){
case "1":
case "true":
case "yes":
case "y":
case 1:
case true:
return true;
break;
default: return false;
}
}
function getUrlSymbol(str){
if(str.indexOf("?")!=-1)
return "&"
else
return "?"
}
function dhtmlDragAndDropObject(){
this.lastLanding=0;
this.dragNode=0;
this.dragStartNode=0;
this.dragStartObject=0;
this.tempDOMU=null;
this.tempDOMM=null;
this.waitDrag=0;
if(window.dhtmlDragAndDrop)return window.dhtmlDragAndDrop;
window.dhtmlDragAndDrop=this;
return this;
};
dhtmlDragAndDropObject.prototype.removeDraggableItem=function(htmlNode){
htmlNode.onmousedown=null;
htmlNode.dragStarter=null;
htmlNode.dragLanding=null;
}
dhtmlDragAndDropObject.prototype.addDraggableItem=function(htmlNode,dhtmlObject){
htmlNode.onmousedown=this.preCreateDragCopy;
htmlNode.dragStarter=dhtmlObject;
this.addDragLanding(htmlNode,dhtmlObject);
}
dhtmlDragAndDropObject.prototype.addDragLanding=function(htmlNode,dhtmlObject){
htmlNode.dragLanding=dhtmlObject;
}
dhtmlDragAndDropObject.prototype.preCreateDragCopy=function(e)
{
if(window.dhtmlDragAndDrop.waitDrag){
window.dhtmlDragAndDrop.waitDrag=0;
document.body.onmouseup=window.dhtmlDragAndDrop.tempDOMU;
document.body.onmousemove=window.dhtmlDragAndDrop.tempDOMM;
return;
}
window.dhtmlDragAndDrop.waitDrag=1;
window.dhtmlDragAndDrop.tempDOMU=document.body.onmouseup;
window.dhtmlDragAndDrop.tempDOMM=document.body.onmousemove;
window.dhtmlDragAndDrop.dragStartNode=this;
window.dhtmlDragAndDrop.dragStartObject=this.dragStarter;
document.body.onmouseup=window.dhtmlDragAndDrop.preCreateDragCopy;
document.body.onmousemove=window.dhtmlDragAndDrop.callDrag;
};
dhtmlDragAndDropObject.prototype.callDrag=function(e){
if(!e)e=window.event;
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash