Hiding E-Mail addresses with JavaScript


Quick Overview

Many people put a link on their homepage to email them directly. This is done using a link with the form mailto:address@domain.com. The problem is that many spambots pick up on this sort of thing. This document will show how to hide an email from spambots, while displaying it to a user

How Do I?

Insert the following into your page wherever you want your email address to appear:

&lt;script type="text/javascript"&gt;<br />
&lt;!--<br />
varE=('email@' + 'domain.com')<br />
document.write(' &lt;A href="mailto:' + varE + '"&gt;' + varE +
'&lt;/a&gt;')<br />
//--&gt;&lt;/script&gt;

This prints a link dynamically, but since most spambots don’t process JavaScript, they can’t see it. Also note that by creating the string using varE=('email@' + 'mikeage.net'), they can’t see it by looking through the source.

Enjoy.


Leave a Reply

Your email address will not be published. Required fields are marked *