Which browsers support console.log()?

后端 未结 8 1517
生来不讨喜
生来不讨喜 2020-12-03 13:12

Do all browsers support this? I would like to output an error using console.log() but was wondering if this supported by all browsers?

console.         


        
8条回答
  •  抹茶落季
    2020-12-03 14:17

    Here is a workaround for when console.log() is not available. You have to retrieve the console.logs yourself.

      if (!window.console) window.console = {};
      if (!window.console.log) 
      {
        window.console.logs = [];
        window.console.log = function (string)
        {
          window.console.logs.push(string);
        };
      }
    

提交回复
热议问题