Mailnull Logo
MailNull.com
Home
About
Documentation

Create Free Account

Login

Insure request.
Click for https.

Search this site

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 language="JavaScript">
<!--
  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 language="JavaScript"> 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 MailNull.
Copyright 2016 by Gray Watson
http://mailnull.com/protect/javascript_email_obfuscation.shtml

Free Spam Protection   Eggnog Recipe   Android ORM   Simple Java Magic   JMX using HTTP   OAuth 2.0 Simple Example   Great Eggnog Recipe  

Your host: ec2-54-161-105-39.compute-1.amazonaws.com 54.161.105.39:47692
Agent: CCBot/2.0 (http://commoncrawl.org/faq/)