Ways to disable JavaScript console debugging

Source: Internet
Author: User

This article mainly introduces the way to disable JavaScript console debugging, the need for friends can refer to the following

Several giant companies, Facebook and Netflix, have decided to prohibit users from executing JavaScript commands in the console (console).  Initially this was started by Facebook to prevent malicious users from executing specific command-mongering messages via the JavaScript console (sending a lot of spam to all Facebook users).     Of course this is a lot of blame, but before I get involved, the code they use is as follows: The code is as follows://It looks like Netflix is the only Facebook took direction [https://news.ycombinator.com/item?id=7222129].  (function () {try {var $_console$$ = console; Object.defineproperty (window, "console", {get:function () {if ($_CONSOLE$$._COMMANDLINEAPI) throw "Sorry, this site is disabled for user security  Console scripting feature ";    Return $_console$$}, Set:function ($val $$) {$_console$$ = $val $$}}) \ catch ($ignore $$) {}}) (); Although I am two-bit, in fact I think this practice is legal.    From their point of view, if you temporarily disable the console to help prevent a problem, you have to do so.    But in the long run it's really not a good idea; The goal may be simply to shield the target users who depend on them. Anyway, if you want to prevent the console from executing the script, the code looks good and it does.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.