Displaying annoying error messages in JavaScript

The following code has no practical use. You have been warned.

Who hasn’t wanted to occasionally annoy users with a bunch of error messages? Well, here is an easy method using JavaScript to throw up a bunch of error messages to stop them from being productive. The code is easy to follow, but basically, I create an Array of error messages, then loop through them, generating a “confirm” box until either the user has exhausted all errors or gives up, clicks “No”, or leaves your site never to return:

    <script type=”text/javascript”>
        function GenerateMessages(count) {
            var messages = new Array(‘Are you sure’, ‘No, seriously, are you really sure?’, ‘Come on, this is a big decision. Think about it for minute. Still want to do it?’, ‘There is no shame is canceling. Are you really sure?’, ‘Would your mother approve of this decision?’, ‘No is an acceptable answer, just ask Nancy Reagan. Giving into peer pressure and saying Yes?’, ‘Last chance. You are going to go through with it, huh?’, ‘OK, I lied. This is your last chance. Super duper sure?’);

            for (var i = 0; i < count; i++) {
                var answer = confirm(messages[i]);

                if (!answer) {
                    alert(‘Good choice!’);
                    return;
                }
            }

            window.location = ‘https://scottstoecker.wordpress.com&#8217;;
        }
    </script>

Then call the script with a button onclick event:

<input type=”button” onclick=”GenerateMessages(8)” value=”Exit” />

Yes, I know, you can’t get that minute of your life back that you spent reading this post, but I appreciate the time.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: