JavaScript hide email address

Posted 23 April, 2009 in Other Stuff

If you want to avoid spam robots crawling your email address, then the following bit of code can help. It breaks up the address, and uses javascript to present it properly to the end user. Just replace your email address with the following, changing id to your name, dom to the site name and tag to the site name tag such as com or net.

<script type=”text/javascript”>
id = “johndoe”;
dom = “example”;
tag = “com”;
document.write(‘<a href=\”mailto:’ + id + ‘@’ + dom + ‘.’ + tag + ‘\”>’);
document.write(id + ‘@’ + dom + ‘.’ + tag + ‘</a>’);
</script>

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Twitter
  • Yahoo! Buzz

Your comment: