Friday, March 9, 2012

No More console.log Errors in IE

Are you really fed up with breaking IE with console.log in javascript?  Add this to the beginning of your JavaScript.  If you're using Ruby on Rails, add it to the beginning of your application.js file.

if (typeof console == "undefined" || typeof console.log == "undefined") {
console = {};
console.log = function(msg) {
// Comment out line below if you want it to ignore console.log altogether in IE
alert(msg);
}
}
view raw application.js hosted with ❤ by GitHub

Code was created during conversation between myself and Slaive. Enjoy!