What happened to console.log in IE8?

后端 未结 17 2473
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 04:45

According to this post it was in the beta, but it\'s not in the release?

17条回答
  •  伪装坚强ぢ
    2020-11-22 05:28

    Make your own console in html .... ;-) This can be imprved but you can start with :

    if (typeof console == "undefined" || typeof console.log === "undefined") {
        var oDiv=document.createElement("div");
        var attr = document.createAttribute('id'); attr.value = 'html-console';
        oDiv.setAttributeNode(attr);
    
    
        var style= document.createAttribute('style');
        style.value = "overflow: auto; color: red; position: fixed; bottom:0; background-color: black; height: 200px; width: 100%; filter: alpha(opacity=80);";
        oDiv.setAttributeNode(style);
    
        var t = document.createElement("h3");
        var tcontent = document.createTextNode('console');
        t.appendChild(tcontent);
        oDiv.appendChild(t);
    
        document.body.appendChild(oDiv);
        var htmlConsole = document.getElementById('html-console');
        window.console = {
            log: function(message) {
                var p = document.createElement("p");
                var content = document.createTextNode(message.toString());
                p.appendChild(content);
                htmlConsole.appendChild(p);
            }
        };
    }
    

提交回复
热议问题