Home
About
Documentation

Create Free Account

Login

Javascript Email Address Obfuscation
How to Hide Your Address

We all need to better protect our email addresses. Spam robots and other agents crawl the web looking for exposed mailto links and other email addresses in the clear. One way to hide your address is to use javascript to encode your email addresses. Although this may only slow down the robots, it seems to be currently effective (July 2006).

So make it work, you put a script into your page (usually in <head>) and then use the script when you want to spit out a mailto: link. The script is:

<script>
<!--
  function myMailto(user, host) {
	e = user + "@";
	for (i = 0; i < host.length - 1; i++) { e = e + host[i] + "."; }
	e = e + host[host.length - 1] ;
	document.writeln("<a href='mailto:" + e + "'>" + e + "</a>");
  }
-->
</script>

when you want to use it, you call it like:

<script> myMailto("foo", [ "bar","com" ]); </script>

This generates:

NOTE: It may be only a matter of time until the spam harvesters start processing javascript.

For more details, see the pages on how to protect your email address.


Please consider donating money to the cause, putting a link to us on your page, and spreading the word about Mailgw.
Copyright 2021 by Gray Watson     Contact site administrators.

Android ORM   Simple Java Magic   JMX using HTTP   Great Eggnog Recipe