Defending your Email Address

As you may, or may not know, evil spam harvesting bots collect email addresses on web pages. There are a few ways to defend yourself. Unfortunately this is yet another thing to think about.

You can put your email address as an image (non clickable) in the page, you could do something like user [at] domain [dot] com, but both of these solutions to the problem do not allow the end user the ease of getting ahold of you.

You can also only put a form on the site, but this forces someone to use the form (some people would rather use an email client). This is a great way to handle the problem, but your email address is still hard coded into HIDDEN form fields (in most cases). The best solution for this method is using PHP (although PHP is not always available), thus your email address is never in the source code.

There is a way to display your email address using javascript to perform a "document.write" and concatenate parts of code and variables together to make the mailto link. This is by far the slickest solution. There is one glaring problem though. This solution does not comply to usability and accessibility standards. It does not pass Government Section 508, or Bobby guidelines. But if usability or accessibility compliance is not your thing, then this javascript tip sure is slick.

<script language="javascript">
<!--
var contact = " Ken Edwards"
var email = "ken"
var emailHost = "meancode.com"
document.write("<a href=" + "mail" + "to:" + email + "@" + emailHost + ">" + contact + "</a>")
//-->
</script>

This script can be put anywhere in the page, it does not have to be in the head region. If you put it in your head region, you will have to break the script up into two, one for the vars and one for the document.write.

Continued on the next page Page 1 — Page 2Page 3

Article tags

Spread the word
Bookmark and Share
Profile image for ken-edwards

Article Author: Ken Edwards

Ken Edwards is the Gaming Editor at Blogcritics, and calls Breaking Windows home. Ken works part time for Student Publications at BGSU as the Webmaster and System Administrator. He is also a freelance web developer.

Visit Ken Edwards's author pageKen Edwards's Blog

Read comments on this article, and add some feedback of your own

Article comments

  • 1 - gerrard

    Mar 05, 2004 at 9:28 am

    You can display encoded HTML entities for display purposes:

    &#64;

    &amp;#64;

  • 2 - Ken Edwards

    Jun 17, 2004 at 2:48 pm

    &#64; displays in browsers like @, i tried

  • 3 - Ken Edwards

    Jun 17, 2004 at 3:44 pm

    fixed it!

Add your comment, speak your mind

Personal attacks are NOT allowed.
Please read our comment policy.
Please preview your comment.

blogcritics lists for Feb 13, 2012

fresh articles Most recent articles site-wide

fresh comments Most recent comments site-wide

most comments Most comments in 24hrs

top writers Most prolific Blogcritics for January

top commenters Most prolific Commenters in 24 hrs