What happened to console.log in IE8?

后端 未结 17 2967
爱一瞬间的悲伤
爱一瞬间的悲伤 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:46

    There are so many Answers. My solution for this was:

    globalNamespace.globalArray = new Array();
    if (typeof console === "undefined" || typeof console.log === "undefined") {
        console = {};
        console.log = function(message) {globalNamespace.globalArray.push(message)};   
    }
    

    In short, if console.log doesn't exists (or in this case, isn't opened) then store the log in a global namespace Array. This way, you're not pestered with millions of alerts and you can still view your logs with the developer console opened or closed.

提交回复
热议问题