在不使用javascript的情况下隐藏来自垃圾邮件的电子邮件 [英] Hiding email from spambots without using javascript

查看:111
本文介绍了在不使用javascript的情况下隐藏来自垃圾邮件的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Ajax的联系我们表单(即依赖于异步请求)。

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

如果用户禁用了javascript,我想显示一个消息,说出类似的内容:

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


您需要启用Javascript才能使用此联系表单。如果您不能或不知道Javascript是什么,请使用您的电子邮件并通过< the_email_address> 与我们联系。

当然,我想从spambots中隐藏 the_email_address

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

由于此电子邮件地址必须显示在< noscript> 中,因此使用Javascript对其进行加密是没有意义的,特别是考虑到某些用户可能会这样做甚至不知道Javascript是什么。

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.

我想到了一个解决方案,但我没办法测试它:插入空的< span>< ; / span> 标签,如

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

或者,有点聪明人


my_em< span style =display:none> garbage< / span> ail @gmail。 com

那会有用吗?如果没有,还有更好的想法吗?

Would that work? If not, any better ideas?

更新

感谢RichieHindle的ansewr 。我以为我会在python中分享一个简单的想法:

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


推荐答案

使用HTML实体对其进行模糊处理。 x@y.com 成为&#120;&#64;&#121;&#46;&#99; &#111;&#109;

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.

在线工具为您进行转换。

这篇关于在不使用javascript的情况下隐藏来自垃圾邮件的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆