Search code examples
javascriptconsole

I try a lot of ways to disabled console but not working. So how to disabled it?


I search on Internet about this, then i tried some ways but it not working. My code:

    <script type="text/javascript">
        (function () {

            var _z = console;
            Object.defineProperty(window, "console", {
                get: function () {
                    if (_z._commandLineAPI) {
                        throw "Sorry, Can't execute scripts!";
                    }
                    return _z;
                },
                set: function (val) {
                    _z = val;
                }
            });

        })();
    </script>

this way not working too!

    <script type="text/javascript">
        window.console.log = function () {
            console.error('Sorry , developers tools are blocked here....');
            window.console.log = function () {
                return false;
            }
        }
    </script>

First I think my browser isn't supporting this code or disabled this, then I try other browser but they aren't working


Solution

  • You cannot do anything about the console or developer tools in general as they are on the client side. Those above used to work, but no longer do since ES6.