Cool JavaScript trick

For those of you that worry about spam and your e-mail address being publicly visible on the internet, this one is dedicated to you.

Additionally, if you ever want to provide a really good service to people that input their e-mail address for display on a forum or comments on a site you build, use this:

<!-- Script to thwart spambot/e-mail address harvesters -->
<script language=javascript>
<!--
var linktext = “Bob“;
var username = “Admin“;
var domain = “website.com“;
document.write(“<a href=“ + “mail“ + “to:“ + username + “@“ + domain + “>“ + linktext + “</a>“);
//-->
</script>

I realize this trick has probably been in use by some clever JavaScript developers for years already but, hey, it's news to me.

No Comments