Dear Dr. Website®: How can I hide e-mail addresses from spammers, while still
including them for legitimate users of my site?
We promise -- this is the last thing we'll have to say on this subject, mainly
because, thanks to a number of readers, we believe we have the ultimate answer (or answers)
to this problem...and we thought it couldn't be done!
The first solution is most suitable for people who like to mess with HTML code, work alone
(anyone else, seeing this in your HTML, would probably fire you because it looks so ugly),
and can dig it -- don't try this with FrontPage!
Courtesy of the people at SiteUp Networks is the Mailto Encoder, which will convert your
real e-mail address to HTML that looks like this:
wdstaff@in
ternet.com
This is simply hard coding for the characters, similar to using ® as a substitute
for ® (the "registered" mark). While the code that SiteUp mails you will look fine
in a browser and work as a mailto: when someone clicks on it, it will not look anything like
an e-mail address to a spammer.
Spammers comb HTML page source with robots looking for addresses of the form foo@bar.com
(hope they try to send to that one!), and obviously they won't be able to do much with
addresses coded this way unless they visit every Web page by hand (come to think of it,
that would be an ideal punishment for a spammer...).
The second solution uses JavaScript, and even if you're not a programmer, you should be able
to handle this one. Basically, the code keeps the mailto:, your name, and your domain
separate in the HTML file, combining them only when the page is browsed. It's a little
bigger in size than the previous solution, but quite clean and it will even work with
FrontPage:
<script language=javascript>
<!--
// SpamProof Mail Script 1.0 by Joseph McLean <flux@thecentre.com> - freeware
// Linktext is the text you want folks to see and click upon.
// email1 & email2 are the text on either side of your email address's @ sign.
var linktext = "Dr. Website";
var email1 = "webdoc";
var email2 = "iw.com";
document.write("<a href=" + "mail" + "to:" + email1 + "@" + email2 + ">" +
linktext + "</a>")
//-->
</script>
A similar -- and even simpler -- script is JavaScriptSource's Email Protector.
Special thanks to our friends at the City of Kalamazoo, Mich., and Mitre for turning us on
to these solutions.