I\'m using Firebug and have some statements like:
console.log(\"...\");
in my page. In IE8 (probably earlier versions too) I get script err
In IE9, if console is not opened, this code:
alert(typeof console);
will show "object", but this code
alert(typeof console.log);
will throw TypeError exception, but not return undefined value;
So, guaranteed version of code will look similar to this:
try {
if (window.console && window.console.log) {
my_console_log = window.console.log;
}
} catch (e) {
my_console_log = function() {};
}
You can use console.log(...) directly in Firefox but not in IEs. In IEs you have to use window.console.
Sometimes console will work in IE8/9 but fail at other times. This erratic behaviour depends on whether you have developer tools open and is described in stackoverflow question Does IE9 support console.log, and is it a real function?