首页  »  网页设计教程  »  1个以JS+xml的树型列表

1个以JS+xml的树型列表

浏览数:共 2949 次     评论:共 0 条     发布日期:2012-04-12     分类:javascript

这是在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.offsetto



上一篇:时钟广告跳转状态栏等JS源码
下一篇:target 属性怎么用 JS 来控制?