Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

How to protect email addresses from harvesting

4:03 pm on Oct 7, 2012 (gmt 0)

Full Member

10+ Year Member

joined:May 21, 2005
posts: 225
votes: 0

Several searches on this topic found mostly entries several years old, so I thought I'd ask again.

To encrypt email addresses in web pages I use:

<script type="text/javascript">
function escramble(){
var a,b,c,d,e,f,g,h,i
a='<a href=\"mai'
g='<img src=\"'
i='\" alt="Email abc" border="0">'
if (f) d=f
else if (h) d=g+h+i
else d=b

This is quite cumbersome.

Is there a cleaner way to achieve the same thing?
5:16 pm on Oct 8, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
votes: 30

Just by relying on JavaScript, you've eluded the vast majority of SPAMmers. Then by obscuring the "mailto:" and exploding the email address into its component parts within your code, you're safe from just about anything short of a JavaScript emulator. So you could compact your code into fewer steps and still be pretty confident in the overall result.

The alternative is to rely on a mail form that never presents the Email address to users in any way. But then you have bots that blindly fill in those forms and you end up with some SPAM regardless of your efforts. So there's no foolproof solution.