Does anybody have a way to detect Firebug opening and closing.
I know you can do the following:
if (window.console && window.console.firebug) {
//Firebug is enabled
}
but this only detects the firebug console on page load. What I want to do is on a page where firebug is not open, detect the opening of the firebug console.
I've tried the following, but with no luck
setInterval(function(){
if(window.console && window.console.firebug){
...
else
...
}, 1000);
Any help greatly appreciated.
Matt
Does anybody have a way to detect Firebug opening and closing.
I know you can do the following:
if (window.console && window.console.firebug) {
//Firebug is enabled
}
but this only detects the firebug console on page load. What I want to do is on a page where firebug is not open, detect the opening of the firebug console.
I've tried the following, but with no luck
setInterval(function(){
if(window.console && window.console.firebug){
...
else
...
}, 1000);
Any help greatly appreciated.
Matt
Share Improve this question asked Sep 19, 2010 at 9:22 Matt BrailsfordMatt Brailsford 2,2373 gold badges29 silver badges41 bronze badges 1- I'm integrating Backfire into a CMS blog.quplo./2010/08/… and would like to only display the Save CSS Changes button when firebug is actually open. – Matt Brailsford Commented Sep 19, 2010 at 9:30
6 Answers
Reset to default 2Simply.. You cant. The firebug window not just an another couple of div element on your page.
The Firebug window.console object is created just before the first Javascript in the page is executed but only if Firebug is active for the page before the first JS and if the user has the Firebug Console panel enabled.
In other words, from within the page you can only detect if the Console is enabled. But for your purposes that should be enough.
We should delete the console property if a user turns Firebug off for a page. I don't know if we actually do that.
Firebug overwrites the console
property of window
, so you may detect it like so:
var _console = window.console;
Object.defineProperty(window, 'console', {
set: function (x) {
if (x.exception) { // check if this is actually Firebug, and not the built-in console
alert('Firebug on');
}
_console = x;
},
get: function () {
return _console;
}
});
The problem is that this object remains when Firebug is closed, so you can't detect that. Maybe there's some other way but I can't find it ATM.
Details:
It's not possible to access Firebug's execution context from document scripts, so we're limited to waiting for Firebug to access some of window
's properties, which does not seem to happen when you close Firebug. Here's some of the events during shutdown, taken with FBTrace:
I've searched the stacktrace for "leaks" to window
, but couldn't find any.
console.table() returns "_firebugIgnore" if firebug is running.
if( window.console && (console.firebug ||
console.table && /firebug/i.test(console.table()) ))
{
alert('Firebug is running');
}else{
alert('Firebug is not found');
}
you can make it as
var t = setTimeout("CheckFireBug()",10000);
function CheckFireBug() {
var t = setTimeout("CheckFireBug()",10000);
if (window.console && window.console.firebug) {
//Firebug is enabled
console.debug('Firebug is enabled.');
} else {
//Firebug is not enabled
console.debug('Firebug is not enabled.');
}
}
If you only want to detect Firebug opening/closing you can check window resize/blur events.