Will Fris's WordPress Weblog

{20080927}   firebug-fallback for non-firefox browsers

When you are developing a page and use firebug stuff inside your script, you might find that in other browsers your javascript does not get executed.

You could include the external javascript file to enable firebug inside other browsers. This can be done since firebug is written out with javascript, isn’t that nice?
Instructions can be found on firebug’s website.

Another option is to provide fake-functions||methods||thingies||whatever that will capture the firebug-calls from your script and do nothing at all besides that.

As demonstrated in many places, for instance:

However, it didn’t work here. (
Ubuntu 8.04 i.e. Hardy Heron
FireFox 3. 0.3(a.t.m.)
FireBug installed from the Ubuntu repostiories

So I fiddled somewhat:
if (window.console){
  for (index in window.console){
    console.log(index + ' >' + window.console[index]);

This gives me everything of window.console if I am not mistaken.

Long story short, no window.console.firebug || console.firebug
So I decided to do a check for something else, namely firebugVersion()
Which give me this script:

if (!window.console || !window.console.firebugVersion)
  var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
  window.console = {};
  for (i in names)
    window.console[names[i]] = function() {};

This works for me,
not giving me errors in Opera
and giving me console-stuff in firefox.


graste says:

Nice. I modified your code for personal use by a few lines to give me a drop-in replacement for the usage of firebug methods in Opera w/ Dragonfly. I posted my results. Btw, I had to use window.console.firebug instead of firebugVersion (Ubuntu 8.04/FF 3.0.3/Firebug 1.2.1). 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

et cetera
%d bloggers like this: