且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查Chrome开发工具是否已打开?

更新时间:2023-09-30 10:45:16

google是你的朋友在这里

p>

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

from 这个问题



这个函数返回true就是用户拥有开发者工具打开
$ b 编辑

回应您的评论

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

格式不正确jQUery,请尝试:

  $('点击(function(){
alert(isInspectOpen());
});


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?

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