1. JavaScript / Говнокод #2317

    +166.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    function InitializeSubmenu(submenucontainerid, tablecellroid, tablecellid, fname) { 
    var s = "";
    s = s + "function " + fname + "() { ";
    s = s + "document.getElementById(submenucontainerid).style.visibility='';";
    s = s + "BringToFront(submenucontainerid);";
    s = s + "}";
    if ((index = navigator.userAgent.indexOf("MSIE")) >= 0)
    s = s + "document.getElementById('" + tablecellid + "').attachEvent(\"onmouseover\", " + fname + ");";
    else
    s = s + "document.getElementById('" + tablecellid + "').addEventListener(\"mouseover\", " + fname + ", true);";
    s = s + "document.getElementById(tablecellroid).onclick = function() {";
    s = s + "if( document.createEvent ) {";
    s = s + "var evObj = document.createEvent('MouseEvents');";
    s = s + "evObj.initEvent( 'click', true, false );";
    s = s + "document.getElementById(tablecellid).dispatchEvent(evObj);";
    s = s + "} else if( document.createEventObject ) {";
    s = s + "document.getElementById(tablecellid).fireEvent('onclick');";
    s = s + "}";
    s = s + "}";
    eval(s);
    }

    Как говориться, "eval() is evil" :-)
    http://stackoverflow.com/questions/197769/when-is-javascripts-eval-not-evil

    Запостил: ramanowski, 23 Декабря 2009

    Комментарии (2) RSS

    Добавить комментарий