What happened to console.log in IE8?

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

    I'm using Walter's approach from above (see: https://stackoverflow.com/a/14246240/3076102)

    I mix in a solution I found here https://stackoverflow.com/a/7967670 to properly show Objects.

    This means the trap function becomes:

    function trap(){
        if(debugging){
            // create an Array from the arguments Object           
            var args = Array.prototype.slice.call(arguments);
            // console.raw captures the raw args, without converting toString
            console.raw.push(args);
            var index;
            for (index = 0; index < args.length; ++index) {
                //fix for objects
                if(typeof args[index] === 'object'){ 
                    args[index] = JSON.stringify(args[index],null,'\t').replace(/\n/g,'
    ').replace(/\t/g,'   '); } } var message = args.join(' '); console.messages.push(message); // instead of a fallback function we use the next few lines to output logs // at the bottom of the page with jQuery if($){ if($('#_console_log').length == 0) $('body').append($('
    ').attr('id', '_console_log')); $('#_console_log').append(message).append($('
    ')); } } }

    I hope this is helpful:-)

提交回复
热议问题