I'm trying to come up with a JavaScript email obfuscator to reduce the chance for spam in emails listed on a web site. Right now I've got a JavaScript based obfuscator that uses a combination of HTML encoding & JavaScript to convert an obfuscated email into a normal email transparently.
What I do is this:
Format the "mailto:" part of the href in links to be HTML encoded like:
mailto:
I also encode the email, replacing the @
sign with (a)
, so that the email reads something like:
stackoverflow(a)example.com
I then use some JavaScript to decipher all mailto links which have this (a)
sign in the email and convert them to @
on page load.
This works fairly well. For people using browsers with JavaScript enabled, they see everything working normally. For people without JavaScript enabled, every mail client I know would consider the email address as invalid, however the user should be able to infer what is needed to correct the symbol.
I was wondering if there was any better (less intrusive (or at best, not very intrusive) but more spammer resistant) way of obfuscating emails on a web page.
As with any type of obfuscation, if a human or computer can easily de-obfuscate it, then a spammer could easily do the same. Because of this, I'm not expecting a foolproof obfuscation, however I was curious to see what other suggestions were out there. Searching Google didn't reveal any solutions that I consider better than my current solution. I was wondering if there were any other good alternatives.