Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>toString (2017-2018)</h2> <p>Since the original asker doesn't seem to be around anymore and this is still the accepted answer, adding this solution for visibility. Credit goes to <a href="https://stackoverflow.com/users/84283">Antonin Hildebrand</a>'s <a href="https://stackoverflow.com/questions/7798748/find-out-whether-chrome-console-is-open/7809413#comment62884356_30638226">comment</a> on <a href="https://stackoverflow.com/users/1068602/zswang">zswang</a>'s <a href="https://stackoverflow.com/a/30638226/629493">answer</a>. This solution takes advantage of the fact that <code>toString()</code> is not called on logged objects unless the console is open.</p> <pre class="lang-js prettyprint-override"><code>var devtools = /./; devtools.toString = function() { this.opened = true; } console.log('%c', devtools); // devtools.opened will become true if/when the console is opened </code></pre> <h2>console.profiles (2013)</h2> <p><strong>Update:</strong> <code>console.profiles</code> has been removed from Chrome. This solution no longer works.</p> <p>Thanks to <a href="https://stackoverflow.com/users/89484">Paul Irish</a> for pointing out this solution from <a href="http://discover-devtools.codeschool.com/chapters/1/challenges/1" rel="noreferrer">Discover DevTools</a>, using the profiler:</p> <pre><code>function isInspectOpen() { console.profile(); console.profileEnd(); if (console.clear) console.clear(); return console.profiles.length &gt; 0; } </code></pre> <h2>window.innerHeight (2011)</h2> <p>This other option can detect the docked inspector being <em>opened, after</em> the page loads, but will not be able to detect an undocked inspector, or if the inspector was already open on page load. There is also some potential for false positives.</p> <pre><code>window.onresize = function() { if ((window.outerHeight - window.innerHeight) &gt; 100) alert('Docked inspector was opened'); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload