How to protect from spam bots your email published on web site

Posted by Stanislav Furman  on February 16, 2012

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);
 });

Comments

Golden says:
February 17, 2012 at 08:06 pm
My simple version, without jQuery:

function gtr(name, domain)
{
if (domain == '')
domain = name_of_s + String.fromCharCode(46) + dom_ain;
mmm = String.fromCharCod(109) + String.fromCharCode(97) + "i" + String.fromCharCode(108) + String.fromCharCode(116) + String.fromCharCode(111) + String.fromCharCode(58) + name +
String.fromCharCode(64) + domain;
document.location.href = mmm;
}

In html:
<a href="JavaScript:gtr('myemail','yahoo.com')">myemail<img alt="[dog]" src="dog.gif"/>yahoo.com</a>
Flag as SPAM  |  Permalink
Smithe681 says:
June 22, 2014 at 08:10 am
Excellent blog here! Also your web site loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my website loaded up as quickly as yours lol ekeafcddadkdddkb
Flag as SPAM  |  Permalink
Stanislav Furman says:
June 22, 2014 at 10:59 pm
Smithe681,

I hope it's a sarcastic note? It's currently hosted on GoDaddy's servers. Never tie up with them! Worse hosting ever. This website will move to a dedicated host soon.
Flag as SPAM  |  Permalink

Leave your comment

Fields with * are required.

* When you submit a comment, you agree with Terms and Conditions of Use.