Skip to content

禁用浏览器开发者工具 #91

@Dream4ever

Description

@Dream4ever

需求描述

需要禁用浏览器开发者工具,以免网站代码被查看。

方案调研

在查看微信读书 Web 版的时候,一打开 Chrome 的开发者工具,就始终处于调试代码的状态,无法查看网站源码。

之后在搜索如何禁用开发者工具的时候,在 Stack Overflow 上看到了这篇提问:How to disable browser developer tools?,里面的一个回答用的如下代码,刚好就是微信读书 Web 版所采用的方式:

(function(){
  debugger
}())

在自己的网页上测试了一下这段代码,debugger 只会生效一次。如果要达到微信读书那种无限出现的效果,还得再改改代码。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Front-endEverything you see and experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions