mootools_使用MooTools JavaScript进行电子邮件保护

mootools

Important Note: This article has been updated here.

重要说明:本文已在此处更新。

We all know how spammers write scripts to slurp pages and collect as many emails as they possibly can, right? Well, I've created a really easy way to avoid this problem using MooTools JavaScript. Let me show you the process.

我们都知道垃圾邮件发送者如何编写脚本来吸引页面并收集尽可能多的电子邮件,对吗? 好吧,我已经创建了使用MooTools JavaScript避免这种问题的非常简单的方法。 让我告诉你这个过程。

XHTML (The XHTML)


	<a href="/david|davidwalsh.name" class="email" title="Email me.">David Walsh</a>


We create a link with the CSS class "email". The email address is inside the href attribute, but the "@" is replaced with "|". Worthless to a spammer's slurp script. The href's beginning "/" is an IE workaround.

我们使用CSS类“ email”创建一个链接。 电子邮件地址位于href属性内,但“ @”替换为“ |”。 垃圾邮件发送者的脚脚本毫无用处。 href的开头“ /”是IE解决方法。

MooTools JavaScript (The MooTools JavaScript)


$$('.email').each(function(el) { 
	el.set('href','mailto:' + el.get('href').replace('|','@').replace('/','')); 
});


Once the DOM is ready (as always), we grab each link with the email class. We take each link's href (the modified email address) and reformat the address so that it acts as a normal email link.

一旦DOM准备就绪(一如既往),我们将获取电子邮件类的每个链接。 我们获取每个链接的href (修改后的电子邮件地址)并重新设置地址格式,以使其充当普通的电子邮件链接。

Have a better solution? Share it!

有更好的解决方案吗? 分享它!

翻译自: https://davidwalsh.name/email-protection-mootools-javascript

mootools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值