楼主不厚道
居然站了沙发!!

解决方案 »

  1.   

    <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;
    }
    //<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>