views:

100

answers:

3

I have a "contact us" form that uses Ajax (i.e. relies on asynchronous requests).

In case the user has javascript disabled, I want to display a message, saying something like:

You need to enable Javascript to use this contact form. If you can't, or don't know what Javascript is, then use your email and contact us at <the_email_address>.

But of course, I want to hide the_email_address from spambots.

Since this email address has to be displayed inside a <noscript>, it makes no sense to scramble it with Javascript, specially given the fact that some users may simply not even know what Javascript is.

I thought of a solution but I have no way to test it: Inserting empty <span></span> tags, as in

my_em<span></span>ail@g<span></span>mail.com

Or, a bit cleverer

my_em<span style="display:none">garbage</span>[email protected]

Would that work? If not, any better ideas?

Update

Thanks RichieHindle for the ansewr. I thought I'd share a simple implementation of the idea in python:

def html_nospam(string):
    def ent(char):
        return "&#%d;" % ord(char)
    return ''.join([ent(c) for c in string])
A: 

Make it an image. Or use Flash (or Silverlight, ActiveX, whatever).

Yar
+4  A: 
Shoban
+1, Use a pencil instead of inventing a pen that works in 0 gravity. Eh? Good one.
Cyril Gupta
+1, of course! Why didn't I think of that?
hasen j
Oh wait, I think I did. The problem is it's not copy-paste-able
hasen j
@hasen j if it's not copy-paste-able then it's a little bit harder to be spam-able? :P
pageman
@pageman, but also more likely for visitors to mistype it, or be confused (and pissed) because they can't select/copy the email address.
hasen j
+4  A: 

Use HTML entities to obfuscate it. [email protected] becomes &#120;&#64;&#121;&#46;&#99;&#111;&#109;.

You'd think address harvesters would be wise to that, but many aren't. The end result for the user (whether he's using a browser or a screenreader) is indistinguishable from the normal text.

There are online tools you can use to do the conversion for you.

RichieHindle
Awesome. This sounds like the way to do it.
hasen j
@hasen, it is - I have seen this quite often.
Arnis L.
sarnath'd to this - but I think this is the way to go or as Shoban suggested, you can try the Facebook way - the email addresses in their profiles are images.
pageman