列出指定对象的所有属性方法树 楼主不厚道居然站了沙发!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <title>+ 页面对象属性方法列表 +</title><style>#tree {float:left;width:200;word-wrap:break-word;}#right {float:right; position:absolute;left: 200px; right: 1in; top: 1px;}</style><div id="tree"></div><div id="right"><A HREF="33" name="linktest">33</A><textarea cols='80' rows='20' name='info' id='info' ></textarea><BR><INPUT TYPE='button' onclick='showprop(document,"document")' value='listtree'><BR><textarea cols='30' rows='5' name='evaltext' ></textarea><textarea cols='30' rows='5' id='evalresult' ></textarea><INPUT TYPE='button' onclick='evalstr(evaltext)' value='eval'><BR></div><!-- script start --><script>var s='';var r='';var i=1;//var tmp='';function evalstr(obj){ res = eval(obj.value); evalresult.value =res;}//<function showprop 取出指定对象的属性方法子对象。function showprop(obj,objid){tmp='';tmpobject='';tmptext='';if (typeof(obj) == "undefined"){obj = eval(objid);//alert(obj);}for(x in obj){if (x==0){alert('null object');break;}//<elseelse { node = objid +"." + x ; nodevalue = eval(objid+"."+x); //nodevalue can be object or string if(nodevalue == "[object]"){ link =nodevalue+'<a href=# onclick=\'showprop('+ node +',\"'+node+'\")\'>'+node+'</a>'; tmpobject += link + "\n"; } else{ tmptext += node +"="+nodevalue +"\n"; }} // else/>}//for 结束tmp = tmpobject +tmptext; tmp = "<pre>"+tmp+"</pre>";document.getElementById('info').value = '';document.getElementById('info').value = tmp;document.getElementById('tree').innerHTML = '';document.getElementById('tree').innerHTML = tmp;document.getElementById('evalresult').value = tmp.length;alert(tmp.length);}// </function showprop>// <function getprop>function getprop(obj,objid){/*var s = "";for(var i in window) s += "window."+ i +" = "+ window[i] +"\n";alert(s);break;*/for(x in obj){if (x==0){break;}else{str=objid+"."+x;pattern=/[^a-z\_A-Z0-9\.]/ig;var arr=str.match(pattern);info2.value=arr;if(!arr) //如果对象为规则,符合eval的要求,规则的对象名由0-9a-Z_组成{tmp += objid +"." + x + " = "+ eval(objid+"."+x) +"\n" ; if((eval(objid + "."+x)=="[object]") ) //if[object]是否为对象。{var objsub;objsub=eval(objid+"."+x);objsubid=objid+"."+x;if(objsubid.search(/document/i)==-1) //如果将document也循环,那么将陷入死循环。{//因为每个对象都有子对象document.if(objsubid.search(/(parent)/i)==-1) //parent也不可以{getprop(objsub,objsubid);info2.value=tmp;i++;}} // if 非document对象结束}//if [object] 结束}//if 判断对象是否规则结束}//else 结束i++;if(i>2000)break;}//for 结束s +=tmp;tmp='';info.value=s;info2.value=i;} // </function getprop></script> 在div中加入sapn设置span属性float:right在ie6下换行怎么解决? 如何通过javascript修改xml里节点的属性值??急!! 火狐浏览器怎么获取选中的文本 tab选项问题 网页幻灯片效果代码 onmouseout 在线等 表格选中哪一行的问题?、 为什么这样使用innerHTML不行?在线等 有关“菜单显示”的问题 如何去掉这个右键时出现的对话框的加密. 如何给页面所有图像添加事件使之可以动态改变大小? javascript中<select>没有onselect事件,如何实现...
<style>
#tree {float:left;width:200;word-wrap:break-word;}
#right {float:right; position:absolute;left: 200px; right: 1in; top: 1px;}
</style><div id="tree">
</div>
<div id="right">
<A HREF="33" name="linktest">33</A>
<textarea cols='80' rows='20' name='info' id='info' ></textarea><BR>
<INPUT TYPE='button' onclick='showprop(document,"document")' value='listtree'><BR><textarea cols='30' rows='5' name='evaltext' ></textarea>
<textarea cols='30' rows='5' id='evalresult' ></textarea>
<INPUT TYPE='button' onclick='evalstr(evaltext)' value='eval'>
<BR>
</div>
<!-- script start -->
<script>
var s='';
var r='';
var i=1;
//var tmp='';
function evalstr(obj){
res = eval(obj.value);
evalresult.value =res;
}//<function showprop 取出指定对象的属性方法子对象。
function showprop(obj,objid)
{
tmp='';
tmpobject='';
tmptext='';if (typeof(obj) == "undefined")
{
obj = eval(objid);
//alert(obj);
}
for(x in obj)
{
if (x==0){
alert('null object');
break;
}
//<else
else {
node = objid +"." + x ;
nodevalue = eval(objid+"."+x); //nodevalue can be object or string if(nodevalue == "[object]"){
link =nodevalue+'<a href=# onclick=\'showprop('+ node +',\"'+node+'\")\'>'+node+'</a>';
tmpobject += link + "\n";
}
else{
tmptext += node +"="+nodevalue +"\n";
}
} // else/>
}//for 结束
tmp = tmpobject +tmptext;
tmp = "<pre>"+tmp+"</pre>";document.getElementById('info').value = '';
document.getElementById('info').value = tmp;
document.getElementById('tree').innerHTML = '';
document.getElementById('tree').innerHTML = tmp;
document.getElementById('evalresult').value = tmp.length;
alert(tmp.length);
}
// </function showprop>
// <function getprop>
function getprop(obj,objid)
{/*
var s = "";
for(var i in window) s += "window."+ i +" = "+ window[i] +"\n";
alert(s);
break;
*/
for(x in obj)
{
if (x==0){
break;
}
else
{
str=objid+"."+x;
pattern=/[^a-z\_A-Z0-9\.]/ig;
var arr=str.match(pattern);
info2.value=arr;
if(!arr) //如果对象为规则,符合eval的要求,规则的对象名由0-9a-Z_组成
{tmp += objid +"." + x + " = "+ eval(objid+"."+x) +"\n" ; if((eval(objid + "."+x)=="[object]") ) //if[object]是否为对象。
{var objsub;
objsub=eval(objid+"."+x);
objsubid=objid+"."+x;
if(objsubid.search(/document/i)==-1) //如果将document也循环,那么将陷入死循环。
{//因为每个对象都有子对象document.
if(objsubid.search(/(parent)/i)==-1) //parent也不可以
{
getprop(objsub,objsubid);
info2.value=tmp;
i++;
}
} // if 非document对象结束
}//if [object] 结束
}//if 判断对象是否规则结束
}//else 结束
i++;
if(i>2000)break;
}//for 结束
s +=tmp;
tmp='';
info.value=s;
info2.value=i;} // </function getprop></script>