如何检测Chrome Inspect Element是否正在运行? [英] How to detect Chrome Inspect Element is running or not?

查看:688
本文介绍了如何检测Chrome Inspect Element是否正在运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以检测Chrome Inspect Elements窗口是否正在运行?



例如,如果用户在Chrome中点击检查元素 Hello World 警报。



是否可以?

解决方案

更新这不再工作。



剩余的唯一解决方案是检查Chrome浏览器中的 console.profiles window.outerHeight window.innerHeight 。有一个库 devtools-detect 基于此方法添加 devtoolschange 窗口对象。



或者,正在努力创建Chrome扩展程序,可靠的检测方法,请参阅此 Google网上论坛




以下是如何检查DevTools是否在发现DevTools 互动课程:

 函数(){
console.profile();
console.profileEnd();
if(console.clear){console.clear()};
return console.profiles.length> 0;
}


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?

解决方案

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;
}

这篇关于如何检测Chrome Inspect Element是否正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆