Table of Contents
- Use AJAX to retrieve and insert an email address
- Use CSS to insert an email address
- Further reading
This article is part of a series on Effective methods to protect email addresses from spammers that compares and tests 50 ways to protect email addresses published on a web site.
This example uses “_” characters that are removed by the “replace” method. The characters could be anything.
Use AJAX to retrieve and insert an email address
W3schools.com has a good AJAX Tutorial. The server-side script is PHP in this example, but it can be ASP, Perl, Java, C, or whatever. Its job is to return a text email address. In this example, it always returns “email@example.com”. The example could be extended to use an argument sent by the web page to select which email address to return.
Use CSS to insert an email address
CSS 2 defines a “content” property that inserts new text into a page wherever the style is used. You can use this to insert an email address when a page is loaded and styled. Spammer email harvesters do not understand CSS and will not insert the text. However, harvesters can read the text of a CSS file (even if they don’t understand it) so break up the email address and insert it in two steps.
TheDepot2’s Spider stomping 2k6 web page has more discussion about his method to protect email addresses.
Most current web browsers support this feature of CSS. Unfortunately, Internet Explorer 7 does not.
All of the harvesters were tested on Windows XP SP2. The names of the harvesters are intentionally left off to avoid giving this web page search engine attention for spammers looking for the ”best” harvester to download.
|Plain email address||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√||√|
|Use AJAX to retrieve and insert an email address|
|Use CSS to insert an email address|
Of course, every harvester found the plain email address that was not protected.
CSS text insertion is an effective method, when browsers support it. While most do, Microsoft’s Internet Explorer 7 still does not. Until Microsoft upgrades their browser, CSS text insertion is not widely supported. Even then, the text inserted by CSS cannot be selected for a copy and paste into the visitor’s email program, and it cannot be read by screen readers for the visually impaired. CSS text insertion has poor usability and accessibility.
The principal article of this series on Effective methods to protect email addresses from spammers lists the other series articles, summarizes their results, and provides a list of web resources for further reading.