• No Spam

Easy way to protect yourself from email harvesting bots

I don’t know why but i wanted to find a nice easy way to be able to write an email address on a website without worrying for email harvesting bots. The idea is to not show the email in plaintext anywhere but the rendered HTML. I just think that the username (at) domain (dot) com is really not good enough. I don’t think my solution is perfect just better and will be a little bit harder for bots to crack (but not nearly impossible).

The code:

<a class="unspamail" href="#">
<script type="text/javascript">
var myObjs = document.getElementsByTagName('a');
for (i in myObjs) {
if (myObjs[i].className == 'unspamail') {
myObjs[i].href = 'mailto:'+((!document.createTextNode("f").textContent)?myObjs[i].innerText:myObjs[i].textContent);

The idea behind this is to put spans inside the email adress and not set it a mailto href link then with javascript get the plaintext of the field and set the mailto.

Will be happy to hear comments :)


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>