CMW: Javascript

Here’s a more-or-less simple piece of Javascript that will protect your email address online.

Remember: Google spiders your sites, but so do lots of evil bots, trolling specifically for things like email addresses.

This Javascript generates your email address at the viewer’s browser, so it never appears in your code. Copy and paste this into your HTML document at the place you want the contact link to appear.


<script language=”JavaScript” class=”normal”>
<!– Hide this script from js-challenged browsers —

var name = “glenn”;
var domain = “”;
var first = “Contact”;
var last = “Glenn”;

document.write(‘<a href=\”mailto:’ + name + ‘@’ + domain + ‘\”>’);
document.write(first + ‘ ‘ + last + ‘</a>’);

//  Done Hiding –>

Be especially careful when you’re copying and pasting text with quotation marks.