Protect your email address with javascript

Spam is the bane of mankind's existence. Although modern spam filters do a good job of keeping your inbox clean, you can take some additional steps to protect yourself. One is to prevent your email address from being harvested from your web site. Spammers have crawlers that troll through web pages looking for the pattern, or something similar.

If you want to put an email contact on your web site, but also want to avoid spammers, you can use JavaScript. Here's the code. Copy it into the body of your contact web page, then change the name and site.

<title>How to protect your email address</title>
<script type='text/javascript'>
e = 'name' + '@' + '';
document.write( "<a href='mailto:" + e + "'>" + e + '</a>' );
<noscript>Please turn on JavaScript!</noscript>