views:

360

answers:

3

I've been looking for a solution to use Javascript to open or activate Firebug.

You see by default, Firebug is deactivated/closed at the corner of the status bar.

You need to click the icon to activate Firebug (the icon becomes coloured).

Is there a way to activate Firebug via Javascript in the javascript code?

see following:

 // check if firebug is installed and activated
if(window.console && window.console.firebug){
   // do firebug debugging and so on
}else{
   alert('Firebug is not installed or activated.');
}
+1  A: 

If there is, that option could possibly be a security hazard. Basically, you're telling FF to start up the debugger. If you could tell this debugger to even do a few things more then it could be misused by hackers.

Workshop Alex
that wouldn't be a hazard. think about this: you do a `console.log('test');`. How much harm can that be?
thephpdeveloper
What if there is a flaw in it and a hacker knows how to use it? Most people want Firebug closed on their site since it kills performance, you are the first that I know of that wants it opened. lol
epascarello
not opened on production site. but on development site. definitely i will remove the debugging codes before i put it to production.
thephpdeveloper
Doesn't matter if you're not using it in production. If it is possible then it would appear in production somewhere sooner or later. It could introduce a security risk when the developers of FireBug left an exploit in it. (By accident, of course.)
Workshop Alex
A: 

Well, if Firebug is deactivated then its not active and cannot respond to anything. You have to actually turn it on before it can accept calls from a web page.

Guss
yes for that i definitely know. the probem is, i want to activate it programatically.
thephpdeveloper
Well, you can't if its off - when Firebug is off it does not expose any APIs. You might want to download the source and hack on it a bit.
Guss
Another option might be to use "firebug lite" inside your web page. This will have the advantage that its always available on your website, and also that it will also work on Internet Explorer (and possibly Opera).
Guss
i tried looking at the source. no clue at all. Looks like the only option is to use firebug lite. thanks a lot.
thephpdeveloper
+1  A: 

If you are trying to troubleshoot your own code, you can use the javascript "debugger" command to cause firebug to break on a given line of code. You will have to enable firebug debugging first for that web page. Maybe that's more along the lines of what you were looking for?

I don't think you want to trigger Firebug to open on an end user's browser; this would, at best, cause confusion for the average user.

RMorrisey
that's not the answer to the question. by the way you can't use the "debugger;" command in Javascript. it is only available in the console command line if i'm not wrong.
thephpdeveloper