Languages
[Edit]
EN

JavaScript - display security warning for non-programmers in web browser console

1 points
Created by:
Root-ssh
179450

In this article, we would like to show how to print security warnings in the web browser console that warns non-programmers about dangers caused by pasting, copying, or executing some code there.

Security warning in the web browser for non-programmers.
Security warning in the web browser for non-programmers.

Note: console.log() print was formatted with styles / CSS.

Practical example:

<!doctype html>
<html>
<body>
  <script>

    var headStyle = 'text-shadow: 0px 0px 4px #ff0; font-weight: 700; font-size: 50px; color: red';
    var textStyle = 'font-weight: 700; font-size: 16px; color: blue';
    var warningStyle = 'font-weight: 700; font-size: 20px; color: red';

    console.log(
       '\n' +
       '%cStop!\n' +
       '%cThis feature is created only for software developers.\n' +
       '%cIf someone asked you to copy, paste or do something here don\'t do it!\n\n' +
       '%cIt can be dangerous and can lead to HACKs on your account!\n\n',
       headStyle, textStyle, textStyle, warningStyle
    );

  </script>
</body>
</html>

See also

  1. JavaScript - style console.log() 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join