mootools
Earlier this week I posted an article describing how you can protect your email links from spambots using MooTools. After some suggestions, I've made some improvements to my system.
本周早些时候,我发布了一篇文章,描述了如何使用MooTools保护电子邮件链接免受垃圾邮件攻击 。 经过一些建议,我对系统做了一些改进。
XHTML (The XHTML)
<span rel="david|davidwalsh.name" class="email custom-class">Email me!</span>
I've switched to using a span tag instead of an anchor to prevent search engines from seeing dead links. We put the modified email address in the rel attribute.
我已改用span标签代替锚,以防止搜索引擎看到无效链接。 我们将修改后的电子邮件地址放入rel属性。
MooTools JavaScript (The MooTools JavaScript)
window.addEvent('domready', function() {
$$('.email').each(function(el) {
var anchor = new Element('a', {
href: 'mailto:' + el.get('rel').replace('|','@'),
'class': el.get('class'),
'text': el.get('text')
}).replaces(el);
});
});
I create an anchor element and replace the span element that was originally there.
我创建了一个锚元素,并替换了原来存在的span元素。
Thank you to everyone that shared their ideas -- we came up with a better script!
感谢所有分享想法的人-我们提出了一个更好的脚本!
翻译自: https://davidwalsh.name/email-protection-mootools-javascript-v2
mootools