console.log without firebug

0 Flares 0 Flares ×

console.log is an invaluable javascript logging function which is part of firebug in firefox.

But I’ve been bitten a few times after running the javascript in a browser without firebug as it tries to call a function that does not exist.

A quick and easy solution is create a basic javascript function that can be called in the same way as console.log, such as:

if (typeof console=="undefined"){console={log:function(A){var B=false;if(B){alert(A)}}}}

Nothing ground breaking! – and in this version all log messages are discarded, set B to true to have them pop up in a javascript alert box.

If you need more sophisticated javascript debugging that will work in most browsers then check out firebug lite.

(…if you haven’t heard of firebug and are doing any sort of client side web development then get it)

0 Flares Twitter 0 Facebook 0 Google+ 0 Reddit 0 LinkedIn 0 StumbleUpon 0 Buffer 0 Email -- 0 Flares ×

Leave a Reply

Back to top