javascript 中 window 的對象

來源:互聯網
上載者:User

javascript 中 window 的對象

1:html部分

        Document    <script type="text/javascript" src="jquery-1.8.2.min.js"></script>    <script type="text/javascript" src="Window.js"></script>    


2:css部分

*{    margin: 0px;    padding: 0px;    font-family: "微軟雅黑";    font-size: 14px;}body{    background-color: #3b3c32;    padding-top: 100px;}#window{    width: 1200px;    height: auto;    margin: 0 auto;}ul{    list-style: none;    /*float: left;*/    position: relative;}ul>ul{    margin-left: 60px;    height: auto;}span.type{    font-weight: bolder;    width: 400px;    height: 30px;    float: left;    cursor: default;}span.object0{    color: green;    cursor: pointer;}span.object1{    color: green;    cursor: pointer;}span.object2{    color: green;    cursor: pointer;}span.object3{    color: green;    cursor: pointer;}span.object4{    color: green;    cursor: pointer;}span.object5{    color: green;    cursor: pointer;}span.function{    color: brown;}span.number{    color: #0b6694;}span.string{    color: yellowgreen;}span.boolean{    color: turquoise;}h4{    width: 100%;    text-align: center;    margin-bottom: 30px;    font-size: 18px;    font-weight: bolder;}li{    height: 30px;    line-height: 30px;    float: left;    width: 100%;    color: turquoise;    /*background-color: #808080;*/    /*border-bottom: 1px solid white;*/    overflow: hidden;    /*background-color: lightseagreen;*/}


3:js部分

$(function(){    function printObj(obj,title,after,dept){        var html = '';        //html += ''+title+'';        html += '
    '; //document.write(''); //document.write(''+title+''); for(pro in obj) { if (pro != 'printObj') { var type = typeof obj[pro]; html += '
  • '; html += ''+ title + '.[' + type + ']' +title+'.' + pro + ' = ' + obj[pro] + '
    '; html += '
  • '; } } html += '

' if(after == ''){ $("body").after(html); }else{ $(after).parent().after(html); } $(".object"+dept).bind('click',function(){ if(parseInt($(this).attr("opened")) == 1){ if($(this).parent().next().is("ul")){ var id = $(this).parent().next().attr("id"); //alert(id); $("#"+id).css('display','none'); $(this).attr("opened",'0'); return false; } }else if(parseInt($(this).attr("opened")) == 0){ if($(this).parent().next().is("ul")){ var id = $(this).parent().next().attr("id"); $("#"+id).css('display','block'); $(this).attr("opened",'1'); return false; } }else { var dept = $(this).attr("dept"); $(this).attr("opened", '1'); if (dept == 0) { var obj1 = $(this).attr("object1"); if (window[obj1] == null) { alert('window.' + obj1 + ' is an object but null !!!'); return false; } printObj(window[obj1], 'window-' + obj1, this, 1); } else if (dept == 1) { var obj1 = $(this).attr("object1"); var obj2 = $(this).attr("object2"); if (window[obj1][obj2] == null) { alert('window.' + obj1 + '.' + obj2 + ' is an object but null !!!'); return false; } printObj(window[obj1][obj2], 'window-' + obj1 + '-' + obj2, this, 2); } else if (dept == 2) { var obj1 = $(this).attr("object1"); var obj2 = $(this).attr("object2"); var obj3 = $(this).attr("object3"); if (window[obj1][obj2][obj3] == null) { alert('window.' + obj1 + '.' + obj2 + '.' + obj3 + ' is an object but null !!!'); return false; } printObj(window[obj1][obj2][obj3], 'window-' + obj1 + '-' + obj2 + '-' + obj3, this, 3); } else if (dept == 3) { var obj1 = $(this).attr("object1"); var obj2 = $(this).attr("object2"); var obj3 = $(this).attr("object3"); var obj4 = $(this).attr("object4"); if (window[obj1][obj2][obj3][obj4] == null) { alert('window.' + obj1 + '.' + obj2 + '.' + obj3 + '.' + obj4 + ' is an object but null !!!'); return false; } printObj(window[obj1][obj2][obj3][obj4], 'window-' + obj1 + '-' + obj2 + '-' + obj3 + '-' + obj4, this, 4); } else if (dept == 4) { var obj1 = $(this).attr("object1"); var obj2 = $(this).attr("object2"); var obj3 = $(this).attr("object3"); var obj4 = $(this).attr("object4"); var obj5 = $(this).attr("object5"); if (window[obj1][obj2][obj3][obj4][obj5] == null) { alert('window.' + obj1 + '.' + obj2 + '.' + obj3 + '.' + obj4 + '.' + obj5 + ' is an object but null !!!'); return false; } printObj(window[obj1][obj2][obj3][obj4][obj5], 'window-' + obj1 + '-' + obj2 + '-' + obj3 + '-' + obj4 + '-' + obj5, this, 5); } } return false; }); } //alert('aaa'); printObj(window,'window','',0);});


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.