Hide Your email address

September 4th, 2009

Listing your email address on a website is a very bad idea…spammers find most of their fresh email address in this way. If you REALLY must list your email address on a website please use one of the following safe techniques.

In these examples please substitute your username (everything before the @ symbol) and your hostname (everything after the @ symbol). To use the scripts, just insert them into your page’s HTML wherever you need them to be displayed.

Example 1: Creating mailto link
This code creates a clickable link that launches your email client. You can replace the link text with your own message, but see example 2 if you want to display your email address as the link text.

<script language=javascript>
<!--
var username = "username";
var hostname = "yourdomain.com";
var linktext = "Click Here To Send Me Email";
document.write("<a href=" + "mail" + "to:" + username +
"@" + hostname + ">" + linktext + "</a>")
//-->
</script>

Example 2: Creating a mailto link with your email address showing
Some visitors to your website won’t understand what a mailto link is and they would prefer to see your email address listed ont he website. This code shows your email address in the link so they can copy and paste it:

<script language=javascript>
<!--
var username = "username";
var hostname = "yourdomain.com";
var linktext = username + "@" + hostname;
document.write("<a href=" + "mail" + "to:" + username +
"@" + hostname + ">" + linktext + "</a>")
//-->
</script>

Example 3: Show your email address without a mailto link
This javascript code will show your email address on a website but will not make the email address ‘clickable’. People will be able to cut-ant-past the email address from this text but not click on it:

<script language=javascript>
<!--
var username = "username";
var hostname = "yourdomain.com";
var linktext = username + "@" + hostname;
document.write(username + "@" + hostname)
//-->
</script>