Attorney Approved Web Design Contract

Due to the popularity of our web development contract template, we're offering the contract, estimate, NDA and invoice templates for $199.50 $49.50 if you order by September 06. Click here to learn more.

Buy One Domain Name, Get One Free

Looking for a reliable and affordable Domain Name Registrar? Look no further than Dotster. And for a limited time, we're able to offer our visitors a buy one domain name, get one free promotion. Click here to take advantage of this offer.



Jun 01 2006

Anti-Spam JavaScript Email Link


Filed under: Security » Spam,
Tools:


How to Prevent Spam Bots from Harvesting Your Email Address

The 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, as we have done on our Contact Information page, we can break up this pattern so it will no longer be recognizable by the email harvesters.  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>

 

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.

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 my case, I notify the user that I have used the JavaScript to reduce email spam, and leave them with two options. One, they can turn on JavaScript so they may see my email address, or two, they can use my contact form to get in touch with me.

Average: 5 (1 vote)
Tools:



Encoding email addresses

Thank you! I've been getting soooo much spam this year. I hope this javascript anti-spam technique will help!

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br> <br />
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is used to make sure you are a human visitor and to prevent spam submissions.