使电子邮件地址免受网页上的机器人攻击? [英] Making email addresses safe from bots on a webpage?
问题描述
在网页上放置电子邮件地址时,您是否将它们作为文本放置如下:
When placing email addresses on a webpage do you place them as text like this:
joe.somebody@company.com
或者使用一个聪明的技巧来试图欺骗电子邮件地址收集机器人?例如:
or use a clever trick to try and fool the email address harvester bots? For example:
HTML 转义字符:
joe.somebody@company.com
Javascript 解密器:
function XOR_Crypt(EmailAddress)
{
Result = new String();
for (var i = 0; i < EmailAddress.length; i++)
{
Result += String.fromCharCode(EmailAddress.charCodeAt(i) ^ 128);
}
document.write(Result);
}
XOR_Crypt("êïå®óïíåâïäùÀãïíðáîù®ãïí");
人工解码:
joe.somebodyNOSPAM@company.com
joe.somebody AT company.com
你用什么或者你什至打扰?
What do you use or do you even bother?
推荐答案
在 CSS 中处理内容和属性:
Working with content and attr in CSS:
.cryptedmail:after {
content: attr(data-name) "@" attr(data-domain) "." attr(data-tld);
}
<a href="#" class="cryptedmail"
data-name="info"
data-domain="example"
data-tld="org"
onclick="window.location.href = 'mailto:' + this.dataset.name + '@' + this.dataset.domain + '.' + this.dataset.tld; return false;"></a>
禁用javascript时,只是点击事件不起作用,仍然显示电子邮件.
When javascript is disabled, just the click event will not work, email is still displayed.
另一种有趣的方法(至少没有点击事件)是利用从右到左的标记来覆盖书写方向.更多相关信息:https://en.wikipedia.org/wiki/Right-to-left_mark
Another interesting approach (at least without a click event) would be to make use of the right-to-left mark to override the writing direction. more about this: https://en.wikipedia.org/wiki/Right-to-left_mark
这篇关于使电子邮件地址免受网页上的机器人攻击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!