A FULLY CODE-FORMATTED COPY OF THIS ARTICLE IS AVAILABLE ON THE CODEGOLEM BLOG.
Every time we display a valid e-mail address on our websites, we expose it to spammers’ crawlers and robots.
Crawlers are able to scan our pages, find valid e-mail addressed, and add them to their spam-database.
No wonder, then, if we receive some special cialis offer, even if we never used our e-mail address to register anywhere…
We can use a simple technique to avoid crawlers catching e-mail addresses from our pages, still successfully displaying them to our users, as well as click-enabling them for a mailto-like functionality.
We usually display e-mail address on our pages using simple HTML anchors, or equivalent ASP.NET HyperLink controls like this:
Both of them expose the e-mail address to crawlers, since they render the whole address on the final page.
Finding a way to code e-mail addresses on the source pages, and translating them on the fly using jQuery, should hide the addresses from crawlers.
Let’s say, we will use “email” css class to mark all e-mail addresses within our site, and we will write them down as “myaddress at mydomain.com”…
This could be a jQuery function to add on our pages to translate all e-mail addresses on the fly:
var text = $(this).text();
var address = text.replace(” at “, “@”);
$(this).attr(‘href’, ‘mailto:’ + address);
And the following could be an “encoded” email anchor:
That’s all… simple enough!
Hope you will find it useful enough… too!