Home > Article > Web Front-end > How to determine whether firebug is enabled using javascript
The example in this article describes how to use JavaScript to determine whether firebug is enabled. Share it with everyone for your reference, the details are as follows:
Friends who often use Firefox + Firebug to debug JavaScript know that once firebug is turned on, the running of the page js will be significantly slower.
Can the javascript on the page actively determine whether Firebug is currently enabled?
The answer is yes.
Firebug has been updated for many versions. I have the impression that an old version can be judged by detecting console.firebug, but it is no longer valid now.
The recent versions of firebug can be judged through the console.table() method, whose return value is a string "_firebugIgnore"
The complete demo code is as follows:
<input type="button" value="check_firebug" onclick="check_firebug()"> <script> function check_firebug(){ if( window.console && (console.firebug || console.table && /firebug/i.test(console.table()) ) ){ alert('Firebug正在运行中'); }else{ alert('未检测到Firebug'); } } </script>
This method also has a disadvantage, close After firebug, console.table() still returns "_firebugIgnore", and the page needs to be refreshed. But for most situations, it's enough.
The console.table() method is originally used to view variables or objects in tabular form. The incoming parameter is the variable or object to be viewed. This "_firebugIgnore" is returned without passing parameters. Is it considered an Easter egg?
Example (running in firebug console):
arr=[["aaaa",1,2,3],["bbbb",4,5,6]]; console.table(arr);