Spambots and Email Links
I got a sidetracked a couple of months ago and thought about how the usual email link <a href=”mailto: gets targeted so much by spam bots. To try and get around this, the fact that very few spam bots will be able to parse the javascript within a HTML document lead me to write a really simple script. I can’t imagine this will eliminate all spam from posting an email address on a site, but hopefully it should reduce it significantly.
Since using this script (back in July 2008) none of my customers have complained about receiving spam from having their email address posted on their site…
- Copy and paste the code below between <script> tags in the head of your document, or download the mail2 script
- If you need it to parse an email address other than .co.uk you’ll need to edit line 12
- Where you want the email address to appear, dump in <script type=”text/javascript”>mail2(”joebloggs”,”hotmail”)</script> - this will produce joebloggs@hotmail.co.uk
- Let me know how you get on
/*
JavaScript Mail2 Script
- 2009 Shaun Gill -
http://www.shaungill.co.uk
*/
var d = "mailto:"
var e = "@"
var f = ".co.uk"
function mail2(a,b)
{
document.write('<a href="'+d+a+e+b+f+'">'+a+e+b+f+'</a>');
}