Html – How to show email addresses on the website to avoid spams

email, html, jsp, mailto

I show email on my website as following

 <a href="mailto:[email protected]">Email</a>

But I read the following while analysing my website using woorank.com, what should I do to avoid this?

Malicious bots scrape the web in search of email addresses and plain text email addresses are more likely to be spammed.

Best Solution

In the past I have seen this done with javascript. Basically you assign the email address to javascript variables and change the contents of an element using these. You can also provide a fallback for users with javascript disabled which points them in the direction of a form if you need to. Here's an example

var user = 'foo',    domain = 'bar.com',    element = document.getElementById('email');    element.innerHTML = user + '@' + domain;    //OR    //'<a href="mailto:' + user + '@' + domain + '">Email</a>'  

This way bots never see the email address as they do not load javascript.