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 name@site.com, 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.

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