ignore firebug console when not installed

后端 未结 9 1264
旧时难觅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:40

    You can use this code to check if console object exists

    if('console' in window && 'log' in window.console)
    {
        // code using console.log here
    }
    

    Or this code

    if(typeof window.console != 'undefined'
    && typeof window.console.log != 'undefined')
    {
        // code using console.log here
    }
    

    Also you can read this post http://alexandershapovalov.com/firebug-console-is-not-defined-60/ Inside the post link how to create jQuery wrapper for console

提交回复
热议问题