ignore firebug console when not installed

后端 未结 9 1235
旧时难觅i
旧时难觅i 2021-02-02 04:15

I use Firebug\'s console.log() for debugging my website. If I try viewing my website in browsers without Firebug then I get a console is not defined er

相关标签:
9条回答
  • 2021-02-02 04:57

    Firebug source code provides a file to do this :

    See firebugx.js

    Do not reinvent the wheel every day :)

    0 讨论(0)
  • 2021-02-02 04:59

    I don't think it gets much better than the workaround you link to. It's of course possible to melt it down to just defining console.log() and leave off rest, but in essence, you won't get around a construct like this.

    Only alternative that comes to mind is checking for console.log every time you call it, and that's even more cumbersome.

    0 讨论(0)
  • 2021-02-02 04:59

    My final solution:

    if(!("console" in window)) 
        window.console = {log: function() {}};
    
    0 讨论(0)
提交回复
热议问题