开发者

Helper code to write to firebug logs, that doesn't break if using IE/Chrome etc

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 :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜