错误: 对象不支持此属性或方法
出现错误:行1:错误: 对象不支持此属性或方法
用调试器得到的结果就是:
dTree.o(1); 对象不支持此属性或方法
dTree是一个树形目录控件,原本是放在一个DIV中,我修改后的代码如下,打开页面可以显示,但是点“+”后,就出现如上错误。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Destroydrop » Javascripts » Tree</title>
<link rel="StyleSheet" href="../dtree/dtree.css" type="text/css" />
<script type="text/javascript" src="../dtree/dtree.js"></script>
</head>
<style type="text/css">
.obj{width:222px;height:auto;position:relative;}
.dtree{ width:200px;height:auto;border:1px solid #666666;}
.btn{ width:18px; height:auto;float:left; position:absolute; right:0; top:0; cursor:pointer;}
</style>
<body>
<div id="obj" class="obj">
<div id="box" class="dtree">
<script type="text/javascript">
d = new dTree('d');
d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');
document.write(d);
</script>
</div>
<div class="btn" onclick="set()" id="btn">
<img id="icon" alt="方向" src="../Image/z_menuOpen.gif"/>
</div>
</div>
<script type="text/javascript">
var ig=document.getElementById("obj");
var box=document.getElementById("box");
var btn=document.getElementById("btn");
var w=box.offsetWidth; //边框宽度,就是162px
var isIE = (document.all) ? true : false;
var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}
ig.style.position ="fixed";
//ig.style.zIndex='1000';
ig.style.left='0'+"px";
ig.style.top='130'+"px";
if(isIE6){
//ig.style.position ="absolute";
ig._fixed = Bind(ig, function(){
//ig.style.marginTop = document.documentElement.scrollTop + "px";
ig.style.marginLeft = document.documentElement.scrollLeft + "px";});
ig._fixed()
//window.attachEvent("onscroll", ig._fixed); //当滚动时,保持相对位置
}
function set(){
if(ig.offsetLeft+w==0)
d(1);
else
d(-1);
}
function d(n){
var T=setTimeout("d("+n+")",1);
n=n<0?n-20:n+20
ig.style.left=ig.offsetLeft+n+"px";
if(ig.offsetLeft+w<=0){
clearTimeout(T);
ig.style.left=-w+"px";
document.getElementById("icon").src="../Image/z_menuClose.gif";
//btn.style.backgroundImage
//btn.style.background-image: url('file:///c:/inetpub/wwwroot/ITService/../Image/z_menuClose.gif');
// btn.style.backgroundColor="#0000FF"; //蓝色,关闭的时候
}
if(ig.offsetLeft>=0){
clearTimeout(T);
ig.style.left=0;
document.getElementById("icon").src="../Image/z_menuOpen.gif";
// btn.style.background-image: url('file:///c:/inetpub/wwwroot/ITService/../Image/z_menuOpen.gif');
// btn.style.backgroundColor="#FF0000"; //红色,打开的时候
}
}
</script>
<table>
<tr >
<td height="3000px">
</td>
</tr>
</table>
</body>
</html>