VCA225 Digital Production

Protecting E-mail Addresses

This method of confusing Spambots was created by Keith Bell. His explanation of this method, plus his evaluation of several alternatives can be found at http://www.december14.net/ways/js/nospam.shtml.

Are you sick of spam? Is there any way to stop it? Well, no, we can't do that; but we can take steps to make it difficult for spammers to get our e-mail address.

"Spambots" are robot programs that crawl all over the web looking for web addresses, specifically strings of characters that look like e-mail address like name@company.com. Any email address on a web page—either in the code or in the content—can be found by spambots, who will read it, digest it, and dump it into a spam database. There are an number of methods programmers have developed to prevent this—the best ways seem to involve confusing them with the creative use of a little Javascript, which spambots can't read. Such is the case with this method.

So how is this done? A standard mailto code looks something like this:

<p>Send me an <a href="mailto:name@company.com">yourName[at]company[dot]com</a></p>

 

Now let's modify it slightly with some Javascript:

Send me an <a href="mail.html" onmouseover="this.href='mai' + 'lto:' + 'name' + '@' + 'company.com'">yourName[at]company[dot]com</a>

 

Both look the same on the page. In fact, if a user rolls his mouse over the link the "mailto" address will appear in the browser status bar just as before, and clicking it will launch the mail client and paste the address in the "To" field just as before. The trick here is the "onmouseover" bit: the Javascript "constructs" the e-mail address out of the fragments that follow (note how "mailto" is broken up into "mai" + "lto"). The spambots can't read this—to them it's gibberish.

Only one problem remains; what if the browser doesn't have Javascript enabled? That's becoming less of a concern all of the time, but it still could happen. In that case, the browser will ignore the Javascript and instead follow the link to a page called "mail.html." This is a separate page on the site with an explanation and an alternate way of contacting you. Here's an example of such a page from Keith Bell.

 

Course Outline

Syllabus

Student Resources