I\'m using Firebug and have some statements like:
console.log(\"...\");
in my page. In IE8 (probably earlier versions too) I get script err
Encountered similar problem running console.log in child windows in IE9, created by window.open function.
It seems that in this case console is defined only in parent window and is undefined in child windows until you refresh them. Same applies to children of child windows.
I deal with this issue by wrapping log in next function (below is fragment of module)
getConsole: function()
{
if (typeof console !== 'undefined') return console;
var searchDepthMax = 5,
searchDepth = 0,
context = window.opener;
while (!!context && searchDepth < searchDepthMax)
{
if (typeof context.console !== 'undefined') return context.console;
context = context.opener;
searchDepth++;
}
return null;
},
log: function(message){
var _console = this.getConsole();
if (!!_console) _console.log(message);
}