How to detect Chrome Inspect Element is running or not?
Solution 1
window.onresize = function(){
if((window.outerHeight-window.innerHeight)>100)
alert('hello');
}
In action: http://jsbin.com/ediquk/
Note that it seems like the resize event gets fired twice, so you should check whether you alerted the use already.
Solution 2
UPDATE This no longer works. The property console.profiles
has been removed in Chrome 29.
The only solution that's left is checking the difference between window.outerHeight
and window.innerHeight
as suggested by @Gerben. There is a library devtools-detect based on this method which adds devtoolschange
to the window
object.
Alternatively, there is an effort in progress to create a Chrome extension using a more robust detection method, see this Google Group.
Here's how they check if DevTools are open in the first challenge of Discover DevTools interactive course:
function () {
console.profile();
console.profileEnd();
if(console.clear) { console.clear() };
return console.profiles.length > 0;
}
Comments
-
Mohammed Shannaq over 3 years
Is there any way to detect whether the Chrome Inspect Element window is running?
For example if the user clicks "Inspect Element" in Chrome, the window shows a
Hello World
alert.Is that possible?