Mar 22, 2010
Firebug console bug/erratic behavior
This bug happens quite often and is very hard to pin down. It usually manifests itself as some piece of functionality in your app not working until you open the Firebug console window. If you’re using console.log anywhere in your code-base, this error occurs since the Firebug console window isn’t defined unless it is open and usable.
Luckily, the fix is quite easy. Just surround your console.log() with a check to see if its available:
if ( window.console ) { console.log( whatever ); }
PrasSarkar.com
One Comment, Comment or Ping
The same issue happens in IE 8, without the IE Developer Tools enabled, the ‘console.log’ statements throw errors.
Rather than wrapping each ‘console.log’ statement in a condition, the problem can be solved by using the following code snippet,
if(!window.console || !console.log) {
var console = { log: function () {} };
}
This even prevents the errors in browser’s that do not have the ‘console’ object, or have a custom ‘console’ object but no ‘log’ method defined.
Mar 24th, 2010
Reply to “Firebug console bug/erratic behavior”