检测用户是否打开浏览器控制台的方式

# 方法 一

var x = document.createElement('div');
var isOpening = false;
Object.defineProperty(x, 'id', {
  get:function(){
      // 在这里放入你的代码
     document.write('Console is opened');
  }
});
console.info(x);

# 方法 二

(function () {var re = /x/;
  var i = 0;
  console.log(re);

  re.toString = function () {
    return '第 ' + (++i) + ' 次打开控制台';
  };
})()
发布了302 篇原创文章 · 获赞 61 · 访问量 7637

猜你喜欢

转载自blog.csdn.net/LawssssCat/article/details/104081346