简体   繁体   English

使用JavaScript函数打印电子邮件地址以防止垃圾邮件效果如何?

[英]How good is using a JavaScript function to print an email address for preventing spam?

Something I've recently done on a few sites I've developed for is to create an included JavaScript function which prints an email address based off of an argument. 我最近在一些我开发的网站上所做的事情是创建一个包含的JavaScript函数,该函数根据自变量打印电子邮件地址。 An example below: 下面的例子:

/index.html

...
<head>
<script src="/script/main.js></script>
</head>
<body>
...
<p><script>printEmail('info');</script></p>
...

/script/main.js

function printEmail(a) {
    document.write('<a href="mailto:' + a + '@domain.com">' + a + '@domain.com</a>');
}

The thought process that I have is that the relatively small script should help deter spambots by not including the email address in full anywhere in the source code. 我的想法是,相对较小的脚本应该通过在源代码中的任何位置都不包含完整的电子邮件地址来帮助阻止垃圾邮件发送者。 The only place it becomes readable is through the rendering engine. 它唯一可读的位置是通过渲染引擎。

So is it secure? 这样安全吗? Also, how secure is it compared to other prevention methods? 另外,与其他预防方法相比,它的安全性如何?

If it renders to the page on page load, I don't think this would do anything, since the spam bots would wait for the page to load anyways and then grab the emails. 如果它在页面加载时呈现到页面上,我认为这不会做任何事情,因为垃圾邮件机器人会反正等待页面加载然后抓取电子邮件。

If you make a user action required, like hovering over the email to reveal the full email, at which point the javascript prints it out, I think that would be more effective, and I've seen things like that in use on pages before. 如果您需要采取用户操作,例如将鼠标悬停在电子邮件上以显示完整的电子邮件,然后javascript将其打印出来,我认为这样做会更有效,并且我以前在页面上也看到过类似的用法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM