I've been using the following function for quite sometime and it works
well for me

var log = function(item){
        if(window.console)
                if(trim(window.console.firebug) != '')
                        console.info(item);
}

*The above functions calls a custom trim function just to remove any
leading or trailing space. you can use your own version for it or can
avoid the usage if you wish.
Regards
JP

On Sep 23, 3:28 pm, tan <[EMAIL PROTECTED]> wrote:
> I think Safari has support for the window.console object so you should
> also test for Firefox (user-agent).
>
> On Aug 15, 8:01 pm, Soichi Hayashi <[EMAIL PROTECTED]> wrote:
>
> > I'd rather not put that if statement on every single lines where I use
> > console.log..
>
> > I guess I am looking for something like..
>
> > if(!window.console) {
> >     var console = {
> >        log: function(foo) {//do nothing};
> >        dir: function(foo) {//do nothing};
> >     };
>
> > }
>
> > But I am pretty sure that somebody else has come up with more elegant
> > solution.. I just don't want to reinvent the wheel..
>
> > Thanks,
> > Soichi
>
> > John J Barton wrote:
> > > Why not
> > >  if (window.console) console.log("starting logging");
>
> > > jjb
>
> > > On Aug 15, 8:19 am, Soichi Hayashi <[EMAIL PROTECTED]> wrote:
>
> > >> Hi.
>
> > >> Is there a way to detect that the browser doesn't have firebug installed
> > >> so that "console.log()" will be ignored instead of causing the page to
> > >> crash?
>
> > >> Thanks,
> > >> Soichi

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to