Using console.log() with firebug works locally, but not when published to my live site

后端 未结 3 1828
梦毁少年i
梦毁少年i 2021-01-06 19:43

I\'m using the:

console.log()

method to log messages to firefox (3.6.6)/firebug while working on my webapp. When I view the app locally, it w

相关标签:
3条回答
  • 2021-01-06 20:29

    i found this one which looks even better because it has all the console methods. not just log

    (function(){
       if (!window.console||!console.firebug){
      var methods = [
         "log", "debug", "info", "warn", "error", "assert",
         "dir", "dirxml", "group", "groupEnd", "time", "timeEnd",
         "count", "trace", "profile", "profileEnd"
      ];
      window.console = {};
      for (var i=0; i<methods.length; i++){
         window.console[methods[i]] = function(){};
      }
      }
      })();
    
    0 讨论(0)
  • 2021-01-06 20:31

    You can no longer detect for Firebug using !console.firebug.

    "The console API formerly implemented a console.firebug property. This property was removed from the API in Firebug 1.9.0 in order to prevent sites from detecting whether a user has Firebug installed."

    Console API help on Firebug wiki

    0 讨论(0)
  • 2021-01-06 20:32

    The console object is not defined in FF unless Firebug is open.

    In Chrome it's always defined.

    One way to handle it is to define it if it is not defined:

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