前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >javascript对象查看器

javascript对象查看器

作者头像
用户1183026
发布2018-01-19 09:42:03
1.8K0
发布2018-01-19 09:42:03
举报
文章被收录于专栏:布尔布尔
代码语言: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>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2007-02-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档