Article Image
read

I love Firebug's console.debug() calls and use them often while writing & debugging Javascript. I find it extremely helpful (it does dump out objects after all) and it is much faster than setting a break point and stepping through. So why would I want all of my console.debug calls not to work?

One of (the many) reasons IE sucks is that it doesn't have an equivalent to Firebug*. Until that glorious day arrives when it does, those calls can render the JS non-functioning. If you have ever seen "console is not defined" you're getting warmer. So to 'neutralize' these calls in any other browser not cool enough to have Firebug all you need is these 3 lines. Don't worry, it shouldn't affect Firefox w/ Firebug installed.

if( typeof(console) == "undefined"){
    console = new Object();
    console.debug = function(str){ alert(str); }
}

* Note: Before anyone yells that there is Firebug Lite, I know that. It still doesn't rule nearly as much. Get Firebug Lite here **

** Note, you don't have to use alert(), actually I implore you not to (it's really annoying)

Blog Logo

Jon Dowdle

Jon Dowdle currently works on the internet at a lovely place called InVision.


Published

Color

Jon Dowdle's Blog

The personal blog of Jon Dowdle.

Back to Overview