开发者

Need a little help with anti email spam javascript

开发者 https://www.devze.com 2022-12-21 12:33 出处:网络
I want to protect my website against spambots with javascript. I found this code, I have two questions.

I want to protect my website against spambots with javascript.

I found this code, I have two questions.

1 - Will this code protect my email adres? 2 - Can someone explain me how to add this line:

<SCRIPT TYPE="text/javascript">
emailE=('info@' + 'friesecomputerservice.nl')
document.write('<A href="mailto:' + emailE + '">' + emailE + '</a>')
 //-->
</script> 

This is the line to add:

<span title="Stuur ons een e-mail"

This is what I have, I can't test it at the moment, can you verify it's correct?

<script type="text/javascript">
emailE=('info@' + 'friesecomputerservice.nl')
document.write('<a href="mailto:' + emailE + '">' + '<span title="Stuur ons een e-mail">'+ emailE +'</span>' + '</a>')
 //-->
</scr开发者_运维知识库ipt>


Let's analyse the code together
emailE=('info@' + 'friesecomputerservice.nl')
a var emailE equals a concatenation of 2 strings
which is evaluated to `emailE = 'info@friesecomputerservice.nl'

then second line document.write('<a href="mailto:' + emailE + '">' + '<span title="Stuur ons een e-mail">'+ emailE +'</span>' + '</a>')
Writes is the document an HTML line
which is <a href="mailto:info@friesecomputerservice.nl"><span title="Stuur ons een e-mail">info@friesecomputerservice.nl</span></a>
Which is translated by web-browser into an ordinary link to email

What this script does .. it doesn't write the email in document as it is it makes it bit harder for bots to read the email

although it isn't good enough an ordinary bot can still read your mail clear after HTML markup

I advice you to write your email in a picture, and show it in the page

If you want to create the image dynamically (to encrypt user specific email for example), you can search for a PHP library , that would create the image at the server side


Generally a "decent" bot would be able to analyse the rendered HTML of the page (as in: what you would see on screen), so IMO this wouldn't work - the bot would be able to see the full email address.

I'd go down the route of a contact form with CAPTCHA. I personally don't like an image for the email address, as it (in my experience) annoys end users.

0

精彩评论

暂无评论...
验证码 换一张
取 消