What's a surefire way of detecting whether a user has Firebug enabled?
What's a surefire way of detecting whether a user has Firebug enabled?
Check for the console object (created only with Firebug), like such:
if (window.console && window.console.firebug) {
//Firebug is enabled
}
The Firebug developers have decided to remove window.console.firebug. You can still detect the presence of Firebug by duck typing like
if (window.console && (window.console.firebug || window.console.exception)) {
//Firebug is enabled
}
or various other approaches like
if (document.getUserData('firebug-Token')) ...
if (console.log.toString().indexOf('apply') != -1) ...
if (typeof console.assert(1) == 'string') ...
but in general, there should be no need to actually do so.
If firebug is enabled, window.console will not be undefined. console.firebug will return the version number.
It may be impossible to detect.
Firebug has multiple tabs, which may be disabled separately, and, are now not enabled by default.
GMail as it is can only tell whether or not I have the "console" tab enabled. Probing further than this would likely require security circumvention, and you don't want to go there.
You can use something like this to prevent firebug calls in your code from causing errors if it's not installed.
if (!window.console || !console.firebug) {
(function (m, i) {
window.console = {};
while (i--) {
window.console[m[i]] = function () {};
}
})('log debug info warn error assert dir dirxml trace group groupEnd time timeEnd profile profileEnd count'.split(' '), 16);
}