Is there any 开发者_开发技巧helper code out there that will allow me to write to firebug's log window, but at the same time not break if using IE/chrome etc.
Put this at the top of your first JavaScript include:
if(console === undefined) var console = { log: function() { } };
A simple check for existence should work.
if ("console" in window)
console.log("Log message!");
PS Chrome and IE7/IE8 have a console :-)
精彩评论