How to check if Chrome Dev Tools are opened? [duplicate]

走远了吗. 提交于 2019-12-19 04:05:55

问题


I found in the tutorial on codeschool.com (discover-devtools: http://discover-devtools.codeschool.com/chapters/1/challenges/3) that there is possibility to check if chrome developer tools are open? How to check it's state/get event of (cmd+alt+i) pressed?


回答1:


google is your friend here

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

from This Question

this function will return true is the user has the developer tools open

edit

in response to your comment

$('#header').click(alert(isInspectOpen()))

is not properly formatted jQUery , try:

$('#header').click(function(){
   alert(isInspectOpen());
});



回答2:


You could try a logging framework like log4js or similar. http://log4js.berlios.de/links.html#other

Your code would have less dependency on a specific browser.



来源:https://stackoverflow.com/questions/16765287/how-to-check-if-chrome-dev-tools-are-opened

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!