Hiding Email Addresses from Web Spiders
Hiding Email Addresses from Web Spiders
The spam industry is like on organism that relies on nutrients to sustain itself, and one of its major food sources comes in the form of email addresses collected from web sites. I wrote this article so that web developers and webmasters can help curb the spam industry by keeping one of its major sources of 'food' out of reach.
Can you see the following email address?
Web spiders can't. (If you can't see it, please enable Javascript in your browser's settings). When web spiders search the source code of this web page, they hope to find something like this:
<a href="mailto:moxley@example.com">moxley@example.com</a>When rendered by your browser, it appears exactly like the email address above. Upon reading this code, the spider detects the distinctive pattern of an email address and adds the address to its database. But instead of finding an email address, it finds this...
<script type="text/javascript">writeAddr('moxley', 'example', 'com')</script>
...which doesn't look like an email address at all, yet most of the email address is there, minus
a few symbols.
A small piece of Javascript has been written that writes the email address
dynamically to your browser window.
I've written a Javascript function that takes any number of string arguments.
In this case, 'moxley', 'example', and 'com'.
The Javascript function, named writeAddr(),
takes the first two arguments, 'moxley' and 'example', and writes
them together with an '@' symbol: moxley@example. Then it takes the remaining arguments (in this case, only 'com'),
and writes them too, prepending
each with a period '.'. What we get in this case is moxley@example.com.
The writeAddr() function doesn't just write the address. It writes the browser
link that opens your email client to compose an email to the address.
Here's the writeAddr() function:
<script type="text/javascript">
function writeAddr() {
// Build the address
var i,a=writeAddr.arguments,addr="";
addr += a[0]+"@";
for( i=1; i<a.length; i++ ) {
if( i>1 ) addr += ".";
addr += a[i];
}
// Write html to the browser with the email address
document.write("<a href=\"mailto:"
+ addr + "\">" + addr + "</a>");
}
</script>
I'm not going to explain the details of this function because the point of the article is just to get you up and running with hiding email addresses from web spiders.
Just copy the above code using your computer's Copy & Paste commands, and paste it into your web page. If you have several pages that need to hide email addresses, look at the source code of this page to find out how to link a separate file for the javascript function definition. You'll find the link in the <head> area.
I often sign up for services that post my email address to a web site. I want people to see my address, but I would hate to let web spiders see it. I wish the webmasters of these sites would use a technique like the one illustrated in this article so that I wouldn't have to worry about my address being collected and used to send spam.
