for(var s in window){
 alert('window.'+s+' = '+window[s]);
}

解决方案 »

  1.   

    <span a=1 b=2 c=3 onclick="test(this)">点击查看我的属性集</span>
    <br>
    <br>
    <div id=result></div>
    <script>
    function test( the )
    {
    var str = "" ;
    for( var i = 0 ; i < the.attributes.length ; i++ )
    {
    str += "nodeName:" + the.attributes[ i ].nodeName + "<br>" ;
    str += "nodeType:" + the.attributes[ i ].nodeType + "<br>" ;
    str += "nodeValue:" + the.attributes[ i ].nodeValue + "<br>" ;
    str += "name:" + the.attributes[ i ].name + "<br>" ;
    str += "specified:" + the.attributes[ i ].specified + "<br>" ;
    str += "expando:" + the.attributes[ i ].expando + "<br>" ;
    str += "<br>---------------<br>"
    }
    result.innerHTML = str
    }
    </script>