Return to the HTML Tips
Masking Email Addresses
Note: In code examples I add a period after each left arrow
bracket so the code can be viewed in all email programs. If
you copy and paste, be sure to remove the periods or it won't
work.
Crafted by Jason Difillippo (although I first received a similar idea from Mark Westfall)
Simplicity is often the best solution. I've been poking around for an effective way to hide email addresses from web-crawling spammers. Using ASCII representations of characters within HTML code used to work fairly well, but no longer is that a viable solution. Instead, a simple _JavaScript technique will likely outsmart the bots at least for a while longer. You can vary the code to your liking, but the basics should be easy enough to understand, even if you're not into scripting languages. It may not be a completely spam-proof solution, but certainly better than leaving plain HTML email links in your pages. The bots will have to be extra smart in order to figure out all of the various modifications you can make to this technique. Adding more variables, changing the order of the variable declarations and anything else you can think of will help keep your email address safe.
<.pre>
<.script language=_javascript>
<.!--
var x1 = "bgates";
var x2 = "microsoft.com";
document.write("<.a href=" + "ma" + "ilto:" + x1 + "@" + x2 + ">contact")
//-->
<./script>
<./pre>
[report a broken link by clicking here]