How to Prevent Spam Bots from Harvesting Your Email Address

To sustain this free service, we receive affiliate commissions via some of our links. This doesn’t affect rankings. Our review process.

Junk emailThe basic idea here is to encode your email address so it will not be easily harvested by robots crawling the Internet in search of email addresses. These robots are based on a script that searches for the “mailto:email@example.com” string (this example will probably be harvested, but it won’t do them any good since the email address is not valid). By using JavaScript to generate the email string, we can break up this pattern so it will no longer be recognizable by the email harvesters (this example is based on an email alias from our old company name).  We also escape certain alphabetic characters.  Visit our html escape characters article for a complete list of valid html (and xhtml) escape characters.

<script type="text/javascript">
<!--
emailMe=('&#105;nf' + 'o' + '@' + '&#67;ontra&#99;' + 'tWebDe' + 'velopme' + 'nt.&#99;om')
document.write('<a href="mailto:' + emailMe + '">' + emailMe + '</a>')
//-->
</script>

<noscript>Our email address is scripted to prevent spam.  If you cannot see it, please enable JavaScript or use the Contact Form below to contact me.</noscript>

Since not everyone has JavaScript support turned on, it is a good idea to include the <noscript> tags to notify these users that they are missing out on a feature that relies on JavaScript. In our case, we notify the user that we have used the JavaScript to reduce email spam, and leave them with two options. One, they can turn on JavaScript so they may see our email address, or two, they can use our contact form to get in touch with us.

Disclaimer: This website contains reviews, opinions and information regarding products and services manufactured or provided by third parties. We are not responsible in any way for such products and services, and nothing contained here should be construed as a guarantee of the functionality, utility, safety or reliability of any product or services reviewed or discussed. Please follow the directions provided by the manufacturer or service provider when using any product or service reviewed or discussed on this website.

Alex bring a series of in-depth articles on search marketing and content management systems as well as troubleshooting tips to We Rock Your Web's collection. He is an avid tennis player, nature enthusiast, and hiker, and enjoys spending time with his wife, friends, and dogs, Bella and Lily.

2
Leave a Reply

avatar
newest oldest most voted
Anonymous
Thank you! I’ve been getting soooo much spam this year. I hope this javascript anti-spam technique will help!
Anonymous
Nowadays lots of spammers got into our e mail address and they are that annoying and even pissed us off most of the time. I haven’t try to open yet my JavaScript. But I will include it later. Thank you for the information. I hope it works.

Cathlene