Does IE9 support console.log, and is it a real function?

后端 未结 7 997
醉话见心
醉话见心 2020-11-22 06:16

In which circumstances is window.console.log defined in Internet Explorer 9?

Even when window.console.log is defined, window.console.

7条回答
  •  佛祖请我去吃肉
    2020-11-22 06:38

    After reading the article from Marc Cliament's comment above, I've now changed my all-purpose cross-browser console.log function to look like this:

    function log()
    {
        "use strict";
    
        if (typeof(console) !== "undefined" && console.log !== undefined)
        {
            try
            {
                console.log.apply(console, arguments);
            }
            catch (e)
            {
                var log = Function.prototype.bind.call(console.log, console);
                log.apply(console, arguments);
            }
        }
    }
    

提交回复
热议问题