Email Address Encryption - Reduce Spam

This simple script will hide your e-mail address from spam bots. People have reported more than 80% less spam after implementing this neat trick.

We will use JavaScript to display the e-mail address, just about everyone in the world has JavaScript on their browser, so you shouldn't worry about people not being able to see it.

Quick facts about using this:

  • Works in all JavaScript enabled browsers.
  • Does not allow Spam Bots to see the code for the e-mail addresses, thus making it so they cannot send you spam.
  • These methods have been tested and work 100%.
  • Will not work if someone has JavaScript DISABLED. Some people browse the internet with JavaScript disabled, when they do, they are automatically not able to see 99.9% of web sites online since almost every site uses JavaScript.

How to implement it in your site

First, modify the part to resemble the domain this script will be producing the e-mail. If your e-mail address is then you would enter inside the place where is at.

function generate_address( username ) {
var domain = "";
var atsign = "@";
var addr = username + atsign + domain;
"<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" + addr + "</a>");

Then the following code between your <head> and </head> tags:

<script src="scripts/gen_email.js" type="text/javascript"></script>

Displaying the email address

Now whenever you want to display a certain e-mail address, insert the following code where you want the address displayed:

<script language="javascript" type="text/javascript">
generate_address( "part1" );

You will want to exchange part1 with the first part of your e-mail address. If you e-mail address is you will substitute part1 with the word Sales.

Include this anywhere on your page that you want to display the e-mail address. So instead of using the code:


You will use:

<script language="javascript" type="text/javascript">
generate_address( "something" );

It will produce the same results, but also make it so your address is hidden by spammers! Now that wasn't too hard, was it?

Copyright © Mr. Bob's Web Design, 2005. All Rights Reserved. Use of website and services are subject to the Terms & Conditions