Spambot Invisible Email Addresses

Here is a handy javascript method for foiling those evil spam bots that trawl through the internet harvesting unsuspecting email addresses. It does this by using javascript to produce the email address only when it gets to the users browser.

The script below enables you to change the subject of the email as you go as well - you could add other variables like a link title too if you wished.

The super-paranoid might like to change the variable names used here also.

Firstly, the content of email.js:

function invem(subject) {
var user = “emailprefixhere”;
var dom= “whatever.com”;
var at = “@”;
var addy = user + at + dom;
document.write(’<’ + ‘a’ + ‘ ‘ + ‘href=’ + ‘”mailto:’ + addy + ‘?Subject=’ + subject + ‘”>’);
}

Save the above as email.js in your scripts folder and link to it in the head of your document like this:

<script src="scripts/email.js" type="text/javascript"></script>

Then in the body of the document, call the function with the following code where you want an email to appear, for example:

<script type="text/javascript">
<!–
invem( “Website enquiry” );
document.write ( ‘email me</a>’ );
//–>
</script><noscript><a href=’contact.htm’ title=’Complete my contact form’>contact me</a></noscript>

If you wish to make the user changeable and for the email address to be visible to the human eye on your site, here’s the content of email.js:

function invem(user, subject) {
var dom = “whatever.com”;
var at = “@”;
var addy = user + at + dom;
document.write(’<’ + ‘a’ + ‘ ‘ + ‘href=’ + ‘”mailto:’ + address + ‘?Subject=’ + subject + ‘”>’ + addy + ‘</a>’);
}

and here’s what goes in the body:

<script type="text/javascript">
<!–
invem( “youremailusername, Website enquiry” );
//–>
</script><noscript><a href=’contact.htm’ title=’Complete my contact form’>contact me</a></noscript>