But it works for me!!!

The lines of javascript below, included at the top of your scripts, could save you a lifetime of confusing conversations with clients where they say an application doesn’t work and you can clearly see that it works on your laptop.

The difference is that you have firebug installed and they don’t, so for you console is defined, but for them it is not, so if you leave any references to it in the app it will throw an error for them. But this fixes that;

if(!console) {
 var console = {};
 console.log = function() {
   return null;
 };
}

Related posts:

  1. ImmunodeficiencyI just solvedĀ  a bug which stemmed from the fact...
  2. A useful debugging methodI’m always dismayed by the lack of debugging information out...
  3. This literally changesYou should know that I’ve built up a lot of...
  4. Remove text nodes functionHere’s a fairly useful function for when you’re using javascript...
  5. SortedOne of the problems I had to solve when writing...

Tags: , , ,

2 Responses to “But it works for me!!!”

  1. Jenny L says:

    That’s really handy. I’ve recently got into the delights of Firebug.

    … AND egg!

Leave a Reply

Security Code: