Home > Web Front-end > JS Tutorial > How to determine whether firebug is enabled using javascript

How to determine whether firebug is enabled using javascript

高洛峰
Release: 2016-12-05 14:58:32
Original
893 people have browsed it

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(&#39;Firebug正在运行中&#39;);
  }else{
    alert(&#39;未检测到Firebug&#39;);
  }
}
</script>
Copy after login

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);
Copy after login



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template