Cloaking Exposed Email Addresses

I wrote this simple Javascript back when I was parting because it was 1999. Still using today to keep client emails (and my own) safe from roving trollbot email pirates.

How do they do it? You and I know your code is no secret. Especially if you lay it out there on a rendered page, as in, “Go ahead and email me at [email protected]

<a href="mailto:[email protected] class="showAll" style="color: tellAll;">Send us an email! :)</a>

But the trolling rovers (or is it roving trollers?) can see into your future, and your code and [email protected] is harvested by peeking under your coding skirts. Protecting your client? Nope.

Enter javascript to save the day once again.

I use inline spans and create a style for them that looks just like my link styles.

So we might do this:

<span class="linkEmail" onclick="mail_To('com','myawesomedomain','thisismyemailaddress','My Popular Site','Please send your get rich quick pamphlet immediately. Please find enclosed $250.')">

What’s happening here?