Reputation: 2237
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
Upvotes: 2
Views: 2845
Reputation: 1
If you only want to detect Firebug opening/closing you can check window resize/blur events.
Upvotes: 0
Reputation: 835
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.');
}
}
Upvotes: 1
Reputation: 25381
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');
}
Upvotes: 1
Reputation: 152996
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.
Upvotes: 1
Reputation: 1857
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.
Upvotes: 2
Reputation: 820
Simply.. You cant. The firebug window not just an another couple of div element on your page.
Upvotes: 2