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

后端 未结 7 894
醉话见心
醉话见心 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:45

    console.log is only defined when the console is open. If you want to check for it in your code make sure you check for for it within the window property

    if (window.console)
        console.log(msg)
    

    this throws an exception in IE9 and will not work correctly. Do not do this

    if (console) 
        console.log(msg)
    

提交回复
热议问题