There are exist different ways how to protect your email address against email harvesting by spam bots. However, none of those methods can not give you 100% protection!

In this post I will show you one of those methods. This method I have used by myself and it works well as I can see.


First of all, at the place where you want to display your email address put this code:


  <a href="#" id="contact"><span id="address"></span></a>

As you can see, it's just an empty anchor tag. The idea is to use Java Script and JQuery for displaying your email on a web page, rather than simple displaying of plain text. First of all, we will split your email by parts using the following Java Script:


  var str1 = 'youremail';
  var str2 = 'yourdomain';
  var str3 = '@';
  var str4 = '.';
  var str5 = 'com';
  var str0 = 'mailto:';

Then use the following JQuery code that will replace your empty <a> tag with an email built from separated parts:


 $(document).ready(function() {
   $('#contact').attr('href', str0 + str1 + str3 + str2 + str4 + str5);
   $('#address').text(str1 + str3 + str2 + str4 + str5);
 });