Hiding email from spambots without using javascript

纵饮孤独 提交于 2019-12-14 03:42:24

问题


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



来源:https://stackoverflow.com/questions/1350750/hiding-email-from-spambots-without-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!