Santiago's Nifty Anti-SPAM Devices

Put the meat back in the can


Do you hate junk e-mail? (If not, what's wrong with you?) Did you know that when you put your e-mail address on your web page, you're advertising it to hundreds of spammers that have programs which sift through search engines sniffing out e-mail addresses to deluge with Make Money Fast scams, ads for Porn Sites, worthless "investment tips", and other forms of kipple? But, if you don't put your address on your pages, how can your users contact you? The solution is to use a simple little JavaScript. Most of the sniffer robots just look at the raw HTML that makes up your page; they don't have the time to run all the JavaScript, Java, and other stuff there to see if there's anything yummy in there. The following little script, when inserted into your page, will generate a clickable link to your e-mail address:

<script type="text/javascript"> 
<!-- 

var account="user"; 
var server="mail.myisp.com"; 

document.write("<a href=" + "mail" + "to:" + account + "@" + server + ">" + account + "@" + server + "</a>") 
//--> 
</script>
<noscript>
an e-mail address which cannot be read unless you enable JavaScript
</noscript>

Just replace user with your account name and mail.myisp.com with your mail server. For instance, if your e-mail address is bob@fro.hair.com, then you'd change it to read:

var account="bob"; 
var server="fro.hair.com"; 

The part inside the <noscript> tag is what a user will see if their browser doesn't have JavaScript or if they've disabled it; you can change this as well without breaking the script.

I didn't invent this; I found it somewhere else, but I've made some modifications to it. Feel free to use it on your page, and good luck foiling the spammers!



729 people have viewed this page since 2 April 1999.

© Andrés Santiago Pérez-Bergquist, All rights reserved. The reproduction of this work, by any means electronic, physical, or otherwise, in whole or in part, except for the purposes of review or criticism, without the express written consent of the author, is strictly prohibited. All references to copyrighted and/or trademarked names and ideas held by other individuals and/or corporations should not be considered a challenge to said copyrights and trademarks.

If you wish to contact the author, you may do so at