Hiding email from spambots without using javascrip

2019-04-13 06:31发布

问题:

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>ail@gmail.com

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])

回答1:

Use HTML entities to obfuscate it. x@y.com 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.



回答2:

What about an image?

alt text http://www.codegeeks.net/wp-content/uploads/2009/08/s.png

or use microsoft tag :) to look cool

alt text http://www.codegeeks.net/wp-content/uploads/2009/08/My_Contact_2009829838261.jpeg

Edit: Just read your comment above regarding your audience. Looks like MS tag will be too much for them :)



回答3:

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