Hide your Email Address from Spammers with a Simple JavaScript

Javascripts to hide email addresses from spammers have been around for a while but perhaps you missed this one. I have been using it more and more for my client’s HTML-based websites.

If the email address is: joe@mydomain.com, most websites use:

<a href="mailto:joe@mydomain.com">joe@mydomain.com</a>

That line of basic HTML is easily harvested by spambots. Within a few weeks, the spam will start trickling in. After a few months, there will be a flood of annoying spam emails.

What can you do? Start with a fresh email address and use this small JavaScript:

<script type="text/javascript"><!--
var name = "joe";
var domain = "mydomain.com";
document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
document.write(name + '@' + domain + '</a>');
// --></script>

Simply replace the email address segments in lines 2 and 3. Then, paste the JavaScript into the HTML code for the page (replacing the mailto code). You are done!

Powered by Gregarious (42)
Share and enjoy:
  • Digg
  • del.icio.us
  • Technorati
  • YahooMyWeb
  • Slashdot
  • Reddit
  • blogmarks
  • Furl
  • SphereIt
  • StumbleUpon
  • E-mail this story to a friend!
  • LinkedIn

Comments are closed.