cryptorave 2016

Simple JavaScript technique to prevent email spam

My efforts to reduce spam

Guilherme Gondim

Spammers. They’re a scourge. Particularly loathsome is the way they use automatic programs (called robots or spiders) to crawl around the Web, “harvesting” email addresses from web pages.

That’s why this site presents email address links in a special way to defeat the nefarious robots. But this technique relies on JavaScript — which isn’t enabled in your browser.

Which is why you’ve landed on this page. This means you’ll have to enter the email address (displayed in the image below) manually into your email program.


Sorry for the extra work!

The technique

If you want to do the same on your site, here is the technique:

Instead of using the straight email in the link, as so:

<p>Send mail
    to <a href=""></a>.</p>

…which looks like this in the browser:

Send mail to

Use this version of the link:

<p>Send mail
    to <a onmouseover="this.href='mai'+'lto:'+'recipient'+'@'+''"
          href="antispam.html" >recipient(at)</a>.</p>

…which looks like this in the browser:

Send mail to recipient(at)

That’s all there is to it! If the users’s browser doesn’t support JavaScript, the link takes them to a web page you’ll create named “antispam.html” (which is the page you are now viewing).

Good luck!