Disable JavaScript console debugging

Source: Internet
Author: User

Original article: Disable the User's JavaScript Console

Original Article Date: January 1, March 06, 2014

Translated on: February 1, March 07, 2014

Translated by: Tie


Several giant companies, Facebook and Netflix, have decided to prohibit users from executing JavaScript commands on the console.
This was initially started with Facebook, which was used to prevent malicious users from spreading messages (sending a large amount of junk information to all Facebook users) by executing specific commands on the JavaScript console ).
Of course, this is a lot of criticism, but before I participate, the code they use is as follows:
// It seems Netflix is the only Facebook player. [https://news.ycombinator.com/item? The id = 7222129]. (function () {try {var $ _ console $ = console; Object. defineProperty (window, "console", {get: function () {if ($ _ console $. _ commandLineAPI) throw "sorry, this website has disabled the console Script function for user security"; return $ _ console $}, set: function ($ val $) {$ _ console $ =$ val $ }})} catch ($ ignore $ ){}})();
Although I speak a little bit, I actually think this is legal. From their perspective, if temporarily disabling the console helps prevent a problem, you have to do so.

But in the long run, this is really not a good idea; its goal may be to block the target users that depend on them.

In any case, if you want to prevent the console from executing scripts, this code looks good and 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.