Protect email address from email sniffers

From CodeCodex

Revision as of 18:50, 12 February 2012 by Nostromo (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
JavaScript:

<script type="text/javascript">
function email(anchor)
{
   anchor.href='mailto:'+anchor.innerHTML.toString().replace(/<([a-zA-Z0-9]*)\b[^>]*>|<\/([a-zA-Z0-9]*)\b[^>]*>| |\n/g,'');
}
</script>

<a onclick="email(this);" href="#"><span>v</span><span>a</span><span>l</span><span style="float:right"> </span><span>@propercode</span><span>.com</span></a>