Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console.log IE9 issue

I made a simple Task Manager using local.storage and I'm using console.log to set some variables but with that, the entire task app doesn't work in IE.

Is there any alternative method of doing this?

Here is the fiddle of the working Task Manager in every other browser: http://jsfiddle.net/cRse9c/

like image 396
jQuerybeast Avatar asked Sep 15 '11 01:09

jQuerybeast


2 Answers

If you want to use console.log() and have it not bomb out in IE when the IE debugger is not running, you can place the following in your javascript at the global scope before any console.log() statements execute to give you a dummy console.log() that will keep your console.log() statements from causing errors:

if (!window.console) {window.console = {};}
if (!console.log) {console.log = function() {};}

Of course, if you actually want to see the console.log() output in IE, then you will have to run the IE debugger which will cause console.log() to get defined or use some other debugging environment that defines it.

like image 189
jfriend00 Avatar answered Oct 21 '22 20:10

jfriend00


There's no console.log in IE unless you have Firebug light on. It's gonna turn into a undefined method/variable error

More information here: Does IE9 support console.log, and is it a real function?

like image 24
corroded Avatar answered Oct 21 '22 18:10

corroded