views:

37

answers:

2

Hi,

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>')
 //-->
</script>
+2  A: 

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

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:[email protected]"><span title="Stuur ons een e-mail">[email protected]</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

Radian
One should note though that image based e-mail addresses aren't accessible, so anyone using a screen reader or similar device will be unable to hear your e-mail. You should probably provide some kind of "contact me" form for such users
PatrikAkerstrand
mmm, then one should provide both Image based and Audio based ( narrated ) email addresses
Radian
great answer, thanks!
Chris
A: 

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.

Jamie
Not so much as CAPTCHAs in my experience. I'd go down the route of accepting spammers will find out your email address and filtering the mail.
David Dorward