It’s annoying. There are sorts of crawlers that fetch all sorts of emails from websites and then sell the lists to Chinese and Russian spammers. I believe another term for this is harvesters… Yet, we do need to leave users a means of contacting the site owner / admin / customer service rep. The solution? Javascript / mootools can fix this with 3 lines of code, making it impossible for a crawlers to identify an email address and yet the mailto: link will remain fully functional to the browser.
As usual, stick this in your mootools domready function:
// hidden emails $$("a.mailLink").each(function(el) { el.set("href", "mailto:" + el.get("data-user") + "@" + el.get("data-domain") + "?subject="+ el.get("data-subject")); });
Now, whenever you want to place a mailto: link, format it like so, assigning it the mailLink class:
<a href="mailto:" class="mailLink" data-user="christoff" data-domain="gmail.com" data-subject="link exchange">mail me</a>
We are using element storage behind the data- name space in the style of HTML 5, joining the different parts of the mail address together via javascript. Of course, should you wish to, you can opt for using the title=”” tag and use JSON instead, allowing you to keep to older doctypes, something like this:
<a href="mailto:" class="mailLink" title="{user:'christoff',domain:'gmail.com',subject:'link exchange'}">mail me</a>
You’d have to adjust the script above to process the JSON and to revert the title attribute to something more readable:
// hidden emails, dependencies: JSON $$("a.mailLink").each(function(el) { var mailProperties = JSON.decode(el.get("title")); el.set({ "href": "mailto:" + mailProperties.user + "@" + mailProperties.domain + "?subject="+ mailProperties.subject, "title": "Send a mail to "+ mailProperties.user + "@" + mailProperties.domain }); });
I hope this helps you somewhat.
GitHub flavoured markdown enabled.