Wouldn’t it be nice to post your email address right on your page without having to worry about spam harvesters and other malicious bots?

I do! See an example in the footer section of my Web Development Forums.

I use Javascript to do this. It is a highly effective method for a few reasons:

  1. Javascript output is unsearchable by search engines.
  2. Spam harvesters, and most other bots and spiders ignore javascript to avoid being caught in loops and infinite content generators

Here’s how to do it!

Copy and paste the script below into the HTML content of your webpage right where you want the email link to be.

Next, update the actual email information (change the variable values).
admin = you, hypertextfever = yourdomain, com = your tld (com, net, org, etc.))

Next, I recommend changing the variable names. They are currently female names that start with “s”. This is simply preference. It’s just best to diversify these variable names so that bots don’t get “wise” to it.

A good example would be to change the three instances of “susan” to “charlie”, and “sally” to “chuck”, etc. Please be aware that there are three instances of each.

<script type="text/javascript">
var susan = "admin";
var sally = "@";
var sandra = "hypertextfever";
var sarah = ".";
var sonia = "com";
document.write('<a href="mailto:'+susan+sally+sandra+sarah+sonia+'">'+susan+sally+sandra+sarah+sonia+'</a>');
</script>

Easier than an email form, and it’s more usable too!

About The Author

2 Comments

  1. Thanks for this post Bo.

    This looks like a neat trick to keep out the spam bots. I don’t always like to use contact forms since they seem so impersonal, but every time I put an email address on a website I get tons of spam, so this is a great solution to try out.

  2. Just tried this. Will be interesting to see if I get any spam.

Leave a Reply

Close