zoukankan      html  css  js  c++  java
  • javascript对象查看器

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 3</title>
    </head>

    <body>
    <table border="1">
        
    <tr>
            
    <td id="td">obj</td>
        
    </tr>
    </table>
    </body>
    <script language="javascript">
    <!--
    window.obj 
    = {
        Name : 'lisq',
        Old : 
    24,
        Birthday : '
    1981-7-24',
        O : 
    {
            o : 
    {
                Name : 'lufang'
            }

        }
    ,
        F: 
    function(){
            
    var i = 100
        }

    }




    var td = document.getElementById('td')
    td.onmouseover 
    = function(){
        Show(
    this.innerHTML)
    }


    function ao(a,aa){var ab=0;while(a!=null){ab+=a["offset"+(aa?"Left":"Top")];a=a.offsetParent}return ab}

    var arrDiv = []
    function Show(objDescript){
        
    var o
        
    try{
            o 
    = eval(objDescript)
        }
    catch(e){
            alert(objDescript)
            alert('dead here')
            
    return
        }

        
        
    var div = document.createElement('div')
        div.style.border 
    = 'solid 1px'
        div.style.position 
    = 'absolute'
        
    if(event.srcElement == window){
            div.style.left 
    = event.clientX
            div.style.top 
    = event.clientY
        }
    else{
            div.style.left 
    = ao(event.srcElement.parentElement, true+ 20 + 'px'
            div.style.top  
    = ao(event.srcElement.parentElement, false+ 20 + 'px'
        }

        
    for(p in o){
            
    if(typeof(o[p]) == 'object'){
                
    var descript = objDescript + '["' + p + '"]'
                div.innerHTML 
    += '<span><a onclick=Show(\'' + descript + '\') style="cursor:hand">+</a>+ p + '</span><br />'
            }
    else{
                div.innerHTML 
    += '<span>+ p + ':' + o[p] + '</span><br />'
            }

        }

        document.body.appendChild(div)
        arrDiv.push(div)
        div.onmouseout 
    = function(){
            
    //this.style.display = 'none'
        }

    }

    //-->
    </script>
    </html>
  • 相关阅读:
    对REST的理解
    longest-repeating-character-replacement(难)
    reconstruct-original-digits-from-english(好)
    third-maximum-number
    【好】strong-password-checker,我自己做出来的:)
    arithmetic-slices
    [poj 3159]Candies[差分约束详解][朴素的考虑法]
    POJ 2773 Happy 2006
    MySql安装(rpm)和启动配置
    [51daifan]来吧,一起书写51daifan的成长史吧-让一部分人先安全起来
  • 原文地址:https://www.cnblogs.com/boolean/p/607235.html
Copyright © 2011-2022 走看看